Can anyone help me or direct me to build a regex to validate repeating numbers
eg : 11111111, 2222, 99999999999, etc
It should validate for any length.
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.
Explanation:
If
1should also be a valid match (zero repetitions), use a*instead of the+.If you also want to allow longer repeats (
123123123) useIf the regex should be applied to the entire string (as opposed to finding “repeat-numbers in a longer string), use start- and end-of-line anchors instead of
\b:Edit: How to match the exact opposite, i. e. a number where not all digits are the same (except if the entire number is simply a digit):