How to match the following string using regular expression in JavaScript?
- Has a total of 5 characters
- First 3 charaters are capital letters
- Last 2 characters are only numbers
I have got this pattern, [A-Z]{3}[0-9]{2}, but seems that it’s still missing something.
You also need anchors:
Otherwise, substrings will also match (like
ABC12withinxyzABC1234).^means “start of string”$means “end of string”