Developer Tools

Regex Tester

Test a browser JavaScript regular expression against local text, inspect matches and capture groups, and review supported flags without running the pattern on the page’s UI thread.

JavaScript regex engineCapture-group reportWorker timeout

Test a JavaScript regular expression

Regex Tester

Regex engine: JavaScript. Execute patterns in an isolated local worker with a 1,000 ms timeout.

Input and options
g, i, m, s, u, y; d only if supported. No duplicate flags.

How this tool works and limits

Plain pattern input: do not wrap with / delimiters. Escaped slashes are supported as pattern characters. Flags g/i/m/s/u/y and d when available. Indices count UTF-16 code units. Zero-length global matches advance by a Unicode code point in u mode. Limits: 1 MB text, 10,000 pattern characters, 1,000 matches, bounded 50,000-character preview. Large capture values are truncated only in the match report. Reference: \d digit; \w word; \s whitespace; . any; ^/$ anchors; [] class; () group; ?/*/+ repetition; {n} count. Browser construct support varies. No replacement mode.

Your input is processed locally in your browser and is not uploaded or stored by this tool.

Isolated browser-side testing

Patterns run locally in a dedicated worker with a one-second timeout. This lowers page-freeze risk but does not prove that a regex is safe for every environment.

How to use the regex tester

  1. 1

    Enter a plain JavaScript pattern without wrapping slash delimiters.

  2. 2

    Add supported flags such as g, i, m, s, u, y or d when the browser supports it.

  3. 3

    Paste test text or load a local TXT file.

  4. 4

    Run the test and review match count, positions, full matches and captured groups.

  5. 5

    Check the highlighted preview and revise the pattern against realistic positive and negative cases.

JavaScript regex example

Use the pattern \b[A-Z]{2}\d{4}\b with the g flag against “Refs AB1234 and XY9876”. The tester reports two matches: AB1234 and XY9876. Add the i flag if lowercase letters should also match.

Pattern input and flags

Enter only the pattern body. For example, use \d+, not /\d+/g; flags belong in their own field. The g flag finds repeated matches, i ignores case, m changes line-anchor behavior, s lets dot match line endings, u enables Unicode-aware pattern parsing, y makes matching sticky, and d requests match indices where supported.

Matches, groups and indices

The results include full-match start and end positions, numbered capture groups and named groups. JavaScript indices count UTF-16 code units, so a position may not equal the number of user-perceived characters before an emoji or some combined Unicode text. Large captured values are shortened only in the report.

Why the regex engine matters

Regex syntax varies between JavaScript, Python, PCRE/PHP, Java, .NET and other engines. A pattern that works elsewhere may use unsupported features or different escaping rules. This page tests the browser’s JavaScript RegExp implementation only and has no replacement mode.

Performance and safety limits

  • Worker timeout: pattern execution is stopped after about 1,000 milliseconds.
  • Input limits: test text is limited to 1 MB and the pattern to 10,000 characters.
  • Result limits: no more than 1,000 matches are reported; preview text is bounded.
  • Catastrophic backtracking: a timeout reduces page-freeze risk but does not make a dangerous pattern suitable for a production server.
  • Browser support: newer constructs and the d flag depend on the browser engine.

Related tools

Regex Tester FAQ

Which regex engine does this tool use?

It uses the current browser’s JavaScript RegExp engine.

Should I include slash delimiters?

No. Enter the plain pattern and put flags in the separate Flags field.

Which flags are supported?

The tool checks g, i, m, s, u, y and d when the browser implements them.

Why do emoji affect match indices?

JavaScript reports positions in UTF-16 code units, which may differ from visible character counts.

Can the tester replace matched text?

No. It reports matches and groups but does not provide replacement mode.

Can a regex still be risky after it passes here?

Yes. Test data, engine, timeout and workload may differ in production.

Explore the complete Shopshubb Tools directory or return to Developer Tools.

Scroll to Top
WhatsAppChat with Shopshubb