Developer Tools

Regex Tester

Test a JavaScript regular expression against sample text without sending the pattern or text to a service. Inspect the actual match positions and capture groups, including named groups. A separate worker and a short execution deadline contain expensive backtracking patterns.

Free online tool

Loading tool…

Flags

Try a focused example

Matches run only when you select Test pattern. A disposable Web Worker is terminated after 750 ms so a backtracking pattern cannot lock the page.

Uses your browser’s JavaScript regex engine, not PCRE. Without g, only the first match is returned. y requires a match at the current position, starting at 0.

Inputs stay in this page’s memory. Exported matches may contain sensitive parts of your test text; review them before sharing.

GET STARTED

How to use the Regex Tester

  1. 01

    Enter the pattern without surrounding slash delimiters, then enable the flags your application uses.

  2. 02

    Paste a representative input or load an example. Select Test pattern; execution is never triggered while you type.

  3. 03

    Review match offsets and captures, then copy or download the result as JSON.

Examples

Extract order numbers

Use \bORD-(\d{4})\b with g to find ORD-1042 and capture 1042 without accepting a two-digit order number.

Read individual lines

Use ^TODO: (.+)$ with g and m to extract each TODO line. Without m, the anchors refer to the whole input.

Understand empty matches

An empty pattern can match between characters. With u enabled, the tester advances over a complete Unicode code point after an empty global match.

Match positions and characters

Positions count UTF-16 code units, the indexing convention used by JavaScript strings. An emoji outside the basic multilingual plane takes two units. A displayed start of 2 does not necessarily mean two visible characters came before the match.

Captures and display bounds

The first 200 matches are retained. Match text is clipped to 1,000 units; original length is shown separately. The first 20 numbered and named capture groups are retained at 200 units each. A null capture means the optional group did not participate, while an empty string is a participating zero-length capture.

Engine behavior and execution limits

The tester uses the browser’s ECMAScript engine. It does not translate PCRE, .NET, or Python patterns. The 750 ms deadline includes worker startup; a timeout is a practical local limit, not a benchmark or a proof that a regex is safe on production data.

What to know

  • Patterns: 2,000 characters. Test text: 100,000 UTF-16 units. Supported flags: g, i, m, s, u, y. Browser worker support is required.

Common questions

Why does a pattern match only once?

Without g, JavaScript returns the first match. Enable g to continue through the input. The y flag instead requires a match at the current position and does not search ahead.

Does this detect every ReDoS risk?

No. It terminates this execution when the deadline expires. Runtime can change sharply with different input. Production systems still need their own input limits and safer pattern design.

Is replacement supported?

This tool focuses on matching and capture inspection. It does not run arbitrary JavaScript replacement functions or evaluate expressions.

Sources & references