I am trying to create a RegEx to match a string with the following criterion
- Length 8
- First character must be a letter a-z or A-Z
- The remaining 7 must be numeric 0-9
examples
- a5554444
- B9999999
- c0999999
This is what I have so far
^[0-9]{8}$
What am I missing to check the first character? I tried
^[a-zA-Z][0-9]{8}$
but that’s not working.
I think this is what you want:
the {…} metacharacter only matches the most previous pattern which in your case is [0-9]. the regex interpretation is as follows:
When you put {8} as per your original question, you’ll assume a string length total of 9: the first character being alphabetic case insensitive and the remaining 8 characters being numeric.