I need a sample regular expression to test in Javascript - input starts with one number between 1 to 16 and is followed by 1 letter between A to E only. eg 2B, 8D, 11E, 16A
I have this regex^([1-9]|[0-1][0-6])[A-E]$ but unable to get appropriate result.
Thank you for your time.
^(?:[1-9]|1[0-6])[A-E]$Wiktor Stribiżew– Wiktor Stribiżew2020-06-17 16:48:35 +00:00CommentedJun 17, 2020 at 16:48- Try:
(?:1[0-6]|[1-9])[A-E]... your current pattern is only slightly offTim Biegeleisen– Tim Biegeleisen2020-06-17 16:49:34 +00:00CommentedJun 17, 2020 at 16:49
1 Answer1
The[0-1][0-6] part matches numbers from00 to16.
You want
^(?:[1-9]|1[0-6])[A-E]$See theregex demo and aregex graph:
Details
^- start of string-(?:[1-9]|1[0-6])- a digit from1to9or1followed with a digit from0to6[A-E]-A,B,C,DorE$- end of string.
Sign up to request clarification or add additional context in comments.
1 Comment
Manoj Karki
It worked - many thanks for your time, support and regex useful info.
Explore related questions
See similar questions with these tags.



