I am looking for a regex pattern I want to use in my php name generator script.
It should detect if the string contains three consecutive consonants.
But it should not detect the string if two consecutive consonants of the three consecutive consonants are the same.
Example:
"hello" -> False, because there aren't 3 consecutive consonants.
"matching" -> True, because there are 3 consecutive consonants.
"apple" -> False, although there are 3 consecutive consonants, because two consecutive of them are the same.
Please help me to find such a regex pattern.
(([b-df-hj-np-tv-z])(?!\2)){3}http://gskinner.com/RegExr/?2vtnt
Edit
There’s an edge case with this pattern that it fails if it’s proceeded by the same last consonant.
E.g
xyzzshould matchxyzbut doesn’t.This would be a more accurate pattern.
(([b-df-hj-np-tv-z])(?!\2)){2}[b-df-hj-np-tv-z]