I am trying to implement regex validation for passport number.
My requirement is
I tried with the below regular expression
^(?!0{3,20})[a-zA-Z0-9]{3,20}$
This seems to work for most of the cases, but incase my text contains 3 or more leading zeros, it seems to fail. Such as '00000001'.
Example Matches
Any help would be much appreciated.
What about this?
^(?!^0+$)[a-zA-Z0-9]{3,20}$
Instead of saying 'reject values with 3-20 zeros', we can just say 'reject anything that only contains zeros (regardless of the length, since <3 and >20 fail anyway)