Regex Tester

Regex Tester - Test JavaScript Regular Expressions Online

Type a pattern and sample text to see JavaScript regex matches highlighted immediately. Edit either field and the results update as you type. Everything runs in your browser.

Enter the pattern without the surrounding slashes.

Flags
UTF-8, up to 2 MiB. Pasted text up to 1,000,000 characters.

Enter a pattern and test text to see live matches. Nothing is uploaded.

Matches will appear here as you type.

Replacement preview (optional)

Up to 10,000 characters. Uses JavaScript String.prototype.replace tokens: $& is the whole match, $1 a numbered group, $<name> a named group and $$ a literal dollar sign. The preview is limited to 200,000 characters.

Your pattern and text stay in this browser tab. The original text is not changed.

How to test a regex in your browser

  1. Enter a pattern and flags

    Type the regular expression without slashes, then tick the flags you need. Newlines are written as \n.

  2. Add the text to search

    Paste your sample text or open a UTF-8 text file. The file is read locally and is never uploaded.

  3. Update matches as you type

    Enter a pattern and sample text. Every edit updates the highlighted matches automatically; the list below shows each match with its index, length and capture groups. Open Replacement preview to see the result of a replacement.

Reading the results

The highlight marks each match in the original text, and the list below it shows #1, #2 and so on with the range index-end. A zero-width match (for example from a* or ^) is shown with a caret and no highlighted block. Capture groups appear as $1, $2 or <name>; a group that did not take part in a match is shown as undefined.

When to use this regex tester

Use it to build or debug a regular expression before you paste it into code: check whether a validation pattern really rejects the strings you expect, confirm which part of a log line a group captures, or preview what a find-and-replace will produce. Because the engine is the one built into your browser, the matches you see are the same JavaScript RegExp results your page or script will get.

Regular expression syntax this tool uses

This tester evaluates standard ECMAScript (JavaScript) regular expressions with the RegExp engine of your own browser. That includes character classes, quantifiers, alternation, anchors, lookahead and lookbehind (where the engine supports it), numbered groups, named groups and backreferences. Your browser decides which syntax is available, so a few newer features may be missing in older engines.

Limitations

This is a JavaScript RegExp tester, not a general regex workbench. Syntax and matching can differ from other languages and libraries: a pattern that works here is not a guarantee that the same pattern behaves identically in PCRE, Python, RE2, Java or .NET, and features from those engines (such as recursion or atomic groups) are not supported. A long-running pattern is stopped by the worker time limit, but that limit is a mitigation, not a guarantee against a slow pattern - catastrophic backtracking can still consume CPU until the limit is reached, so keep patterns specific when you test large text. The tool lists at most 1,000 matches and shortens very long match values. Positions are reported as UTF-16 indices, and per-group positions appear only with the d flag.

Regular expression flags

ECMAScript flags you can enable for the test.
FlagMeaning
gGlobal: search for every match. The matches list always enumerates globally.
iIgnore case: match letters regardless of case.
mMultiline: ^ and $ match at line boundaries.
sDotAll: . also matches line-break characters.
uUnicode: treat the pattern as code points. Cannot be combined with v.
vUnicode sets: set notation for character classes. Cannot be combined with u.
ySticky: match only at the position given by lastIndex.
dHas indices: expose start and end positions for each capture group.

Regex Tester FAQ

Is my pattern or text uploaded?

No. The pattern, flags and test text are processed inside a worker on your device. Loading the page itself still makes ordinary website requests (HTML, CSS, JavaScript and a favicon).

Which regular expression flavour does it use?

The JavaScript (ECMAScript) RegExp engine of your own browser. It is not a PCRE, Python or RE2 tester, and results can differ from those engines.

Does it change my original text?

No. Highlighting and the replacement preview are shown separately; the text you entered is left as it is. You can optionally download the replacement as a separate file.

Why did a match stop early or say zero-width?

A pattern such as a* or ^ can match an empty string. The tester advances past an empty match so it does not loop forever, and marks it as zero-width instead of highlighting characters.

What happens with a very slow pattern?

The search runs in a separate worker with a hard time limit. If the pattern does not finish in time the worker is stopped and you get an error instead of a frozen page. That limit reduces the risk of a hang but does not prove a pattern is safe.

How many matches can I see?

Up to 1,000 matches are listed and the first 1,000 are highlighted in the preview. Very long individual matches are shortened in the list while their true length is still reported.