111111111 - Invalid
A121278237 - Invalid
7777777777 - Invalid
121263263 - Valid
111111112 - Valid
111111111 – Invalid A121278237 – Invalid 7777777777 – Invalid 121263263 – Valid 111111112 –
Share
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.
should work. It needs a string of at least two digits to match successfully.
Explanation:
Match a digit and capture it into backreference #1:
([0-9])Assert that it’s impossible to match a string of any length (>1) of the same digit that was just matched, followed by the end of the string:
(?!\1+$)Then match any string of digits until the end of the string:
[0-9]+$EDIT: Of course, in Java you need to escape the backslash inside a string (
"\\").