Using .NET regular expressions.
Let's say I have the following text:
ddddddddddd
And I would like to test for a repetition of more than 2 for any character.
The regex should not return a match for a text containing double letters like the word "look".
Do not assume the input text only consists of repetition of the letter d. I want ANY repetition of characters.
Try this
(.)\1{2,}
See it here on Regexr
The . matches any character, this character is stored in group 1, because of the brackets around it. The \1{2,} checks then for 2 or more of this character (together with the originally matched character then 3 or more.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With