I want regular expression for a string of length 9 and with format of
AAANNNNNA
A- Alphabetic, N-Numeric
And also for AAANNNNNN
Please help me.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First one:
[a-zA-Z]{3}[0-9]{5}[a-zA-Z]Second one:
[a-zA-Z]{3}[0-9]{6}Combined:
[a-zA-Z]{3}[0-9]{5}[a-zA-Z0-9]You can simplify this by using
\dto represent digits:[a-zA-Z]{3}[\d]{5}[a-zA-Z\d]How it works:
[]is a character class.a-zmeans the rangeatoz,A-Zis the same for caps,0-9is0to9. The use of{}afterwards means repeat, so{3}means repeat the previous pattern 3 times.Regex isn’t that hard to learn, go read up on it at http://www.regular-expressions.info/