Firefox gives SyntaxError: invalid regexp group

TLDR; Use named capture groups with caution (or just don't use them)

For me, it was because I thought I'd be clever and try to used named capture groups in my regex... Firefox punished me.

Doesn't work: /(?<text>[a-z]+)/

Does work: /([a-z]+)/


The negative lookbehind (not currently supported in Firefox) is used here to restrict the previous three digits. This restriction can be performed equally well with a negative lookahead, just it needs to be placed before the 3-digit pattern:

(?:[0-35-8]\d\d(?<!(?:000|500|36[7-9]|3[7-9]\d|86[7-9]|8[7-9]\d)))

should look like

(?!000|500|36[7-9]|3[7-9]\d|86[7-9]|8[7-9]\d)[0-35-8]\d\d

Note the non-capturing groups are redundant here, I removed them, and [01235678] = [0-35-8].

The final regex looks like

/^(?:19|20)?\d{2}(?!000|500|36[7-9]|3[7-9]\d|86[7-9]|8[7-9]\d)[0-35-8]\d\d\d{4}[vVxX]$/

See the regex demo and the Regulex graph:

enter image description here