Test regex flags

Test a JavaScript regular expression while seeing how each selected flag changes matching.

freeworks offlinenothing uploaded
ToolRegex Flags Tester
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The expression is compiled with selected flags; case folding, multiline anchors, dot matching, Unicode handling, and global iteration then affect the result. Invalid flag combinations are reported before matching.

  • JavaScript’s standard flags are exposed individually.
  • Global mode changes repeated-match state.

Worked example

Compare case-sensitive vs case-insensitive matching
Compare how different flags affect matching of mixed-case text
Input
											Hello hello HELLO world
										
Output
												Pattern: /hello/
Test string: "Hello hello HELLO world"

Flag      Description                                  Matches
-----------------------------------------------------------------
(none)    (no flags)                                   1
g         g - global                                   1
i         i - case insensitive                         1
m         m - multiline                                1
s         s - dotAll                                   1
gi        gi - global + case insensitive               3
gm        gm - global + multiline                      1
gim       gim - global + case insensitive + multiline  3
gims      gims - all common flags                      3…
											

When to use this

Frontend validation, regex teaching, and pattern debugging test flags.

Edge cases

  • g advances lastIndex between tests.
  • m makes anchors match line boundaries inside multiline text.
  • i folds case but does not normalize arbitrary Unicode characters.

References