Regex Duplicate Flag Error – Remove Repeated g, i, m Flags

Local only

Remove a repeated JavaScript regular-expression flag so the pattern can compile.

7 chars · 1 line

8 chars · 1 line

Pattern did not match the inputFlags: g

Regex flag error

How to fix a duplicate regular expression flag

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

What you can do here

  • JavaScript RegExp validation
  • Broken pattern preloaded
  • Corrected pattern comparison
  • Configurable regex flags
  • Browser-native error feedback
  • Browser-local processing

Steps

  1. Read the flags field separately from the pattern.
  2. Identify any repeated letter such as gg, ii, or mm.
  3. Keep one copy of each intended flag and test again.

Repeating a flag does not strengthen its behavior

g means global matching whether it appears once or twice conceptually. JavaScript syntax therefore requires a unique set of flags rather than repeated letters.

Duplicate regex flag example

Keep one global flag instead of repeating it.

Invalid flags

gg

Corrected flags

g

Common questions

Frequently asked questions

Does gg mean more global matching than g?

No. g is a boolean switch, so one occurrence is enough.

Can I combine g and i?

Yes. Different supported flags can be combined, for example gi.

Does flag order matter?

The combination controls behavior; repeating the same flag is the error addressed here.

Debugging a specific Regex issue? Browse Regex troubleshooting.