Regex in JavaScript - Match a string like "ABC12"
javascript, regex
Solution
You also need anchors:
var regexp = /^[A-Z]{3}[0-9]{2}$/
Otherwise, substrings will also match (like `ABC12` within `xyzABC1234`).
- `^` means "start of string"
- `$` means "end of string"
Problem
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.