Regex Tester Online — JavaScript Match & Replace

A JavaScript regex workshop. Enter the pattern and the test string, then select Test to see inline highlights and match cards with groups, or preview a replacement. Everything runs in your browser, with no upload.

Loading…
Regex tester
A workshop for JavaScript RegExp with flags, cheat-sheet chips, inline highlights on the test string, and match cards with capture groups. Preview a replacement with $1 and $&. Everything runs on the client.

How testing works

Enter a pattern and a test string, toggle flags (g, i, m, s, u, y), then select Test, or use an example or Sample. Matches update when you run the test, not while you type. The left pane highlights hits, and the right pane lists match cards with groups. Replace mode also shows the substituted string. Pathological patterns can freeze the tab, so keep experiments local and avoid nested quantifiers on large subjects.

Options

Flags (g / i / m / s / u / y)
Standard JavaScript RegExp flags. Global (g) finds all matches. The other flags are i for ignoreCase, m for multiline, s for dotAll, u for unicode, and y for sticky. They change how matching works. Here, sticky (y) matches only at the start of the test string, because lastIndex is reset on every run.
Mode (match / replace)
In match mode, the tool only lists hits. In replace mode, it applies a substitution string with $1, $&, and related templates, so you can preview rewrites.
Replace with
Visible in replace mode. Supports JavaScript replacement patterns such as $1 for group 1 and $& for the full match.

Examples

Capture pairs

Pattern + test string

(\w+)=(\d+) on user=42 role=admin env=prod (flag g)

Result

1 match: user=42, with groups [user, 42]. The other pairs have non-digit values, so try the digits example.

Replace with $1

Pattern + test string

(\d+) → [$1] on x=10 (flag g)

Result

x=[10]

Related utilities

Need URL-safe labels? Use slugify. Generate secrets with the password generator.

Regex tester FAQ

Pattern debugging questions

Is this PCRE or Python regex?

No. This tool uses only the JavaScript RegExp engine of your browser, the same flavor as in Node and modern browsers. There is no switch for other flavors.

Do I need to include / delimiters?

Leave the / delimiters out of the pattern field. Or paste /pattern/flags, and we unwrap the pattern and merge the flags for you.

How does sticky (y) work here?

Sticky (y) matches only at the start of the test string here because lastIndex is reset on every run.

Can a pattern freeze my browser?

Yes. Catastrophic backtracking (ReDoS-style patterns) can hang the tab because execution is local. Prefer simple patterns and smaller subjects when experimenting. Very large match sets may be truncated.

Is the email example a full RFC validator?

No. The email-ish example is a practical pattern for demos, not a complete RFC 5322 validator.

Are named groups supported?

Yes. Named captures appear once as GROUP k (name) on each match card, not duplicated as a separate numbered row.

Is my text uploaded?

No. Testing stays in your browser.

Timestamps, UUID, ULID, Nanoid, cron, passwords, regex, slugs, number bases, letter case, text diff, chmod and Lorem Ipsum, all in your browser.