Quick answer
JavaScript regex flags are: g (global), i (ignore case), m (multiline), s (dotall), u (unicode), y (sticky).
Regex Invalid Flags
JavaScript regex flags are: g (global), i (ignore case), m (multiline), s (dotall), u (unicode), y (sticky). Any other character or invalid combination can cause an error.
Common causes
- Using a flag letter not supported (e.g. x or e).
- Passing a string with spaces or non-flag characters.
How to fix
- Use only the letters g, i, m, s, u, y in the flags string.
- Omit flags or use an empty string if you need no modifiers.
- Test with the Regex Tester which accepts g, i, m, s.
Examples
Bad
gi x
Good
gi
FAQ
- What does the 'g' flag do?
- Global: find all matches instead of stopping after the first.
- What does the 's' flag do?
- Dotall: . matches newlines as well.
Fix it now
Try in validator (prefill this example)