Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex to match repeated consonant

Tags:

How can I detect with a regular expression if the same consonant is repeated three or more times?

My idea is to match words like tttool, likkke, or likkkkke

like image 328
user455318 Avatar asked Jun 14 '11 01:06

user455318


1 Answers

Try this:

([b-df-hj-np-tv-z])\1{2,}

Explanation:

  • [b-df-hj-np-tv-z] are all the consonants
  • \1 is the back reference to the 1st group (ie the same character)
  • {2,} means "2 or more of the preceding term", making 3 or more in all

See live demo.

like image 101
Bohemian Avatar answered Oct 06 '22 03:10

Bohemian