Reputation: 13
The following php code only detects some of the patterns
$re = "/([aeiou]+[bcdfghjklmnpqrstvwxyz]+[aeiou]+)/";
$str = "miniature";
preg_match_all($re, $str, $matches);
print_r($matches);
This shows the following results: 'inia' and 'ure'
(Array ( [0] => Array ( [0] => inia [1] => ure ) [1] => Array ( [0] => inia [1] => ure ) ))
Why is it not showing 'iatu' (any number of vowels followed by any numbers of consonant followed by any number of vowels)
How would I write the regex to give me all three results?
Thanks
Upvotes: 1
Views: 41
Reputation: 174696
If you want iatu
to be captured, then use a positive lookahead,
(?=([aeiou]+[bcdfghjklmnpqrstvwxyz]+[aeiou]+))
Upvotes: 3