Reputation: 31
I'm trying to combine two regexes. One will ensure that input contains 14 digits: ^\\d{14}$
and I need another regex to check if all the input is not of the same digit.
Please suggest how I proceed with this. I want my regex to check for that the input is 14 digits and those digits are not all same numbers [0-9].
Is there a way I add the test for finding not all digits are the same with my regex that checks for if the input is exactly 14 digits? I would need one regex expression which combines them both. Thank you!
Upvotes: 0
Views: 80
Reputation: 350272
You can use negative lookahead with a back reference to the first digit:
NB: This is pure regex syntax. I did not escape backslashes for use in a programming language.
Upvotes: 2
Reputation: 1475
There is no regex operation for "match here for all-of-these except a back-reference". You have a two-step test here, not a single one.
Upvotes: -1