Regex tester · Guide
Regex Flags Explained: g, i, m, s and More
Flags change how a regular expression is applied without changing the pattern itself. Knowing them turns a pattern that almost works into one that does.
Global and ignore-case
The global flag (g) returns every match rather than just the first — essential for find-all and replace-all. The ignore-case flag (i) makes letter matching case-insensitive.
Multiline and dotall
Multiline (m) makes ^ and $ match at line boundaries, not just the start and end of the whole string. Dotall (s) makes the dot match newlines too, which is useful for patterns spanning multiple lines.
Combine and test
Flags stack — gi, gm, gims and so on. The tester lets you toggle them and see the effect immediately, which is the quickest way to learn what each one does.
Frequently asked questions
Can I use this for production work?
Yes, for inspection, formatting and quick generation. Still review the output before committing it to production code or configuration.
Ready to try it?
Open the free browser-based Regex tester and apply what you just read — no sign-up, runs locally.
Open the Regex tester tool