I am having a problem creating a regex that suits the following criteria:
This is the regex that I created, but it seems doesn't work. Please help me.
$count = preg_match_all("^(^\bdi|^\bmen]\w*(in|at|ah|iah)((a|e|i|o|u)(wi)((?!(a\e\i\o\u)i$/",$value,$match);
For example, the output should capture word "lain", not "dian".
Try the following regex:
^((?!di|men)[a-z]+(in|at|ah|iah)[aeiou]*(?:wi)?[a-z]*i?)$
Explanation:
^((?!di|men) assert that string does not start with 'di' or 'men'
[a-z]+ one or more sequence of characters a-z
(in|at|ah|iah) ends with on these patterns
[aeiou]* followed by optional sequence of vowels a,e,i,o,u
wi followed by optional 'wi'
[a-z]* optional sequence of characters a-z
i?)$ optional 'i'
Demo here: