7 chars · 1 line
8 chars · 1 line
7 chars · 1 line
8 chars · 1 line
Regex flag error
JavaScript regex flags are switches, not counters. Repeating the same flag, such as gg, is rejected by this tester before RegExp construction. This tool is free to use. No account or payment is required.
Last updated
g means global matching whether it appears once or twice conceptually. JavaScript syntax therefore requires a unique set of flags rather than repeated letters.
Keep one global flag instead of repeating it.
gggCommon questions
No. g is a boolean switch, so one occurrence is enough.
Yes. Different supported flags can be combined, for example gi.
The combination controls behavior; repeating the same flag is the error addressed here.
Debugging a specific Regex issue? Browse Regex troubleshooting.