I am trying to figure out how to write regular expressions in javascript i need to have a three letter group of either ACF, ABQ, or BXD the character after must be hyphen followed by either 6 or 9 then 5 numbers between 0-9
This is my attempt i'm not sure where I am going wrong?
/ACF|ABQ|BXD-^6|9[0-9]{5}
CodePudding user response:
You can group the first 3 alternations in a non capture group, and you should put the ^
at the start of the pattern.
If you want to match 6 or 9 you can use a character class [69]
The $
at the end denotes the end of the string.
The pattern can be written as:
^(?:ACF|ABQ|BXD)-[69][0-9]{5}$