I need a regex that would validate first 4 digit set and then 3 digits. The first foure digits need to be identical.
Acceptable entries should be for example:
7777989
8888767
Invalid entries:
7778888
7777abc
8989123
Now my problem is that in my code iam creating the regexes based on class names. for example something like this
if (currentChar == 'n') regex += '[0-9]';
else if (currentChar == 'd') regex += '^[0-9]+$';
in above code n and d is class name where n represents “any digit” and d represents “identical digits”. So for the above example, the rule would be ddddnnn.
should do it.
A quick and dirty regex generator (in Python), assuming that all
ddigits have to be identical:Result: