A regular expression that characters repeated more than a specified number of times (9 times in this example).
This can be useful in finding the duplicate characters in a string.
/(.)\1{9,}/
Explain:
()
Capturing group #1. Groups multiple tokens together and creates a capture group for extracting a substring or using a backreference..
Dot. Matches any character except line breaks.
\1
Numeric reference. Matches the results of capture group #1.{9,}
Quantifier. Match 9 or more of the preceding token.
Matches:
- aaaaaaaaaa
- aaaaaaaaaaa
- ==========-
Non-matches:
- aaa
- ababababab
See Also:
- Regular Expression To Check For Repeating Numbers
- Regex To Determine If A String Has All Unique Characters
- Regex To Match Consecutive Occurrences Of The Same Character In A String