learner learner - 2 months ago 7
PHP Question

Combining two conditions: Vowel and a space

I am trying to check for two conditions,


  1. The string should contain a vowel.

  2. The string should contain a space.



Here is what I am writing:

$reg = "/(?=.*(\s)) (?=.*(a|e|i|o|u))/";


But on running:

if ( preg_match($reg,"kka "))
echo "YES.";
else
echo "NO.";


I am getting
NO
. What am I doing wrong?

Answer
((?:.*)[aeiouAEIOU]+(?:.*)[ ]+(?:.*))|(?:.*)[ ]+((?:.*)[aeiouAEIOU]+(?:.*))

You can try with this

Explnation