I have a string in php like this.
$str = “ABCCCDE” //Contains repeated character CCC more than 2 times
I want to know if there is any repeated characters more than 2 times using regular expression.
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
(.)will match any character (except new lines), and the\1will match a pattern same as the first matched group — in this case, the character we’ve just matched. So this RegEx will match 3 same consecutive characters.