learner learner - 1 year ago 83
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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download