Tools/Developer Tools/Regex Tester

JavaScript Regex Tester – Test Patterns with Capture Groups

Free online regex tester to test regular expressions against any text. Highlights all matches, shows match count, groups, and index positions instantly.

If this tool isn’t working as expected, please take a screenshot of the error and report the problem here so we can investigate and improve it.

About this tool

JavaScript regex has quirks that PCRE-flavored testers won't surface by default - no atomic groups, no possessive quantifiers, and its own flag set. Testing in the actual JS engine before shipping means fewer production surprises.

This runs the JavaScript RegExp engine - the same one your browser uses. If your regex passes here, it passes in production JS code. Useful for testing patterns before embedding them in validators or parsers, and for debugging when a pattern works in a PCRE tester but not in your JavaScript.

How to Use Regex Tester

Enter Pattern

Type your regex pattern and select the flags you need.

Paste Test Text

Add the string you want to test the pattern against.

See Matches

Matching text is highlighted and match details appear below.

Review Groups

Check match count, index positions, and capture groups.

Common Workflows

Form Validation Testing

Test an email or phone validation regex before adding it to a form.

Match Debugging

Debug a pattern that matches too much or too little.

Parser Group Inspection

Inspect capture group values from a string parser.

Flag Behavior Verification

Verify flag behavior across global, case-insensitive, multiline, and dotAll modes.

Best For

  • Capture groups, match indexes, and full match text all display on every test.
  • Supports four JavaScript regex flags: Global (g), Case insensitive (i), Multiline (m), and DotAll (s).
  • Popular testers like regex101 default to a different engine (PCRE) - results there may differ from JavaScript unless you switch its flavor to ECMAScript. This tool always runs the real JS engine, so there's no flavor to remember to switch.

Examples

Greedy vs lazy quantifiers change what matches

Pattern & Test Text

Pattern: <.+> (greedy) · Test text: <a><b>

Matches

Match 1: <a><b> (index 0) - a single greedy match.

Switching to <.+?> (lazy) instead finds:
Match 1: <a> (index 0)
Match 2: <b> (index 3)

Greedy quantifiers (+, *, {n,}) match as much text as possible; lazy quantifiers (+?, *?) match as little as possible. Add a ? after the quantifier to switch a pattern from greedy to lazy.

Capture groups shown in Match Details

Pattern & Test Text

Pattern: (\d{4})-(\d{2})-(\d{2}) · Test text: 2026-07-12

Match Details

Match 1: 2026-07-12 (index 0)
Group 1: 2026
Group 2: 07
Group 3: 12

Each parenthesized group in the pattern becomes a numbered group in Match Details, in the order the opening parentheses appear - this includes named groups like (?<year>\d{4}), which still show up as "Group 1" rather than by their name.

Toggle the DotAll flag to match across line breaks

Pattern & Flags

Pattern: a.b · Test text: "a" + newline + "b"

Result

Without the s flag: "No matches found for this pattern in the test text."
With the s flag enabled: Match 1: a\nb (index 0)

By default, . doesn't match line-break characters. Turning on the s (DotAll) flag makes . match \n too, so the same pattern then matches across the line break.

Use Cases

Debugging why a pattern fails in JavaScript specifically

Confirm a regex that works in another language or tool actually matches under the real JS RegExp engine, before shipping it in a validator or parser.

Extracting structured values from a string

Use capture groups to pull dates, IDs, or other structured pieces out of a larger string, and inspect exactly what each group captured in the Match Details panel.

Checking how a flag changes matching behavior

Toggle Global, Case Insensitive, Multiline, or DotAll on the same pattern and text to see the effect immediately, instead of guessing from documentation.

Testing a pattern before pasting it into real JS code

Confirm a pattern's match count and capture groups are correct on realistic test text before wiring it into a validator, parser, or form.

Common Mistakes

Problem

Expecting u, y, d, or v flags to be available

Solution

Only four flags are supported: Global (g), Case insensitive (i), Multiline (m), and DotAll (s). Unicode (u), sticky (y), indices (d), and unicodeSets (v) aren't offered as toggles here.

Problem

Assuming Match Details will show a named group by its name

Solution

A pattern like (?<year>\d{4}) still labels its result "Group 1" in the Match Details panel, not "year" - named groups work for matching, but the tool doesn't display the name, only the position.

Problem

Not accounting for the tester's always-global search

Solution

The tool always searches with the Global flag internally to build the highlighted view and match list, even if you haven't toggled it on. If you copy the pattern into your own code without Global, remember it will only find the first match there.

Problem

Forgetting that greedy quantifiers match as much as possible

Solution

A pattern like <.+> against <a><b> matches the whole string in one greedy result, not two separate tags - add a ? after the quantifier (<.+?>) to match as little as possible instead.

Tips & Best Practices

Toggle Global on to match what you'll paste into code

The tool searches globally either way, but turning Global on in the UI keeps the displayed flag string honest about what you're about to copy elsewhere.

Add a ? after a quantifier to make it lazy

*, +, and {n,} match greedily by default. Appending ? (*?, +?) makes them match the shortest possible string instead - useful when a pattern is grabbing more text than expected.

Test against edge-case text, not just the happy path

Try empty strings, multiline text, and text containing the characters your pattern is meant to exclude - the highlighted view makes over-matching and under-matching obvious at a glance.

Limitations

Only four flags: g, i, m, s

Unicode (u), sticky (y), indices (d), and unicodeSets (v) flags aren't available as toggles, even though the underlying JavaScript engine supports them.

Capped at 500 matches

If a pattern matches more than 500 times in the test text, the tool stops collecting results after the 500th match rather than processing the rest.

No replace or split testing

The tool only shows matches and capture groups - there's no way to preview a String.replace() or String.split() result using the pattern.

Named capture groups display by position, not by name

Match Details labels every group "Group 1", "Group 2", and so on by order, even for named groups like (?<year>\d{4}) - the group's captured value shows, but not its name.

Comparisons

JavaScript RegExp vs PCRE-Style Testers

This tool always runs the real JavaScript engine. Many general-purpose regex testers default to PCRE, which handles a few constructs differently - the most common source of a pattern that "works" elsewhere but fails here.

JavaScript (this tool)PCRE (common tester default)
Atomic groups (?>...)Not supportedSupported
Possessive quantifiers (++, *+)Not supportedSupported
Lookbehind (?<=...)Supported in modern engines (variable-length)Supported, with behavior that varies by PCRE version

Which should you use?

A pattern built around atomic groups or possessive quantifiers needs rewriting for JavaScript - there's no direct substitute. Testing here instead of a PCRE-default tool catches that mismatch before it reaches production code.

FAQs

The most common debugging question is why a regex that worked elsewhere fails in JavaScript. The FAQ below covers which flags are supported, how capture groups are shown, and which regex engine this uses.

Which regex flags does this tester support?

This tester supports global (g), case-insensitive (i), multiline (m), and dotAll (s) flags.

Does it show capture groups?

Yes. Each match card shows the full match, its start index, and any named or indexed capture groups.

What regex engine does it use?

It uses the JavaScript built-in RegExp engine - perfect for testing patterns used in Node.js, browsers, and TypeScript.

Get more tools like this

Leave your email so we can prioritize similar tools and updates.

Trending Tools

Trending tools will appear as visitors explore the catalog.

Recently Used

Your recently visited tools will show up here.