learner learner - 10 months ago 51
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.";
echo "NO.";

I am getting
. What am I doing wrong?

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

You can try with this