I am looking for a regex that matches:
Length is between 1 and 10.
The 8th character can be alphanumeric [0-9a-zA-Z] and the rest have to be digits [0-9]
Valid
1
123
1234567890
1234567a
Invalid
1a
123456789a
12345678901
I have tried: [0-9]{1,7}[0-9a-zA-Z][0-9]{0,1} but that is failing miserably
>Solution :
You can match either 1-7 digits, or match 7 digits, the 8th one being [0-9a-zA-Z] and optional 2 digits.
^(?:\d{7}[0-9a-zA-Z]\d{0,2}|\d{1,7})$
^Start of string(?:Non capture group\d{7}[0-9a-zA-Z]\d{0,2}Match 7 digits and one of0-9a-zA-Z]and 2 optional digits|Or\d{1,7}Match 1-7 digits
)Close non capture group$End of string