can someone please help me to compose a regular expression to check an alphanumeric string is in a particular format.
First character must be a letter and the next 6 characters are numbers...eg x279833 or X279833 are both valid.
This is what i've come up with - ^[A-Za-z]{1}[0-9]{6}$
regards
Yours should work just fine (you edited it in after I wrote this answer), but the {1}
is completely unnecessary. You can shorten it a little to use \d
instead of [0-9].
If you want to make sure the entire string is that format, use:
^[a-zA-Z]\d{6}$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With