Regex Tester

Test a regular expression against your text and see every match highlighted and counted as you type. It uses the JavaScript regex engine, not PCRE.

Developer ToolsTrending● Free No upload Instant

Loading Regex Tester…

Your browser is preparing the tool. It runs 100% locally.

Quick answer

Enter a regular expression, choose flags and type a test string. The tool highlights every match and shows how many there are, updating as you type. An invalid pattern shows the error. It uses the browser's JavaScript (ECMAScript) regex engine, so most patterns behave as expected, but advanced syntax can differ from PCRE, Python or .NET. It all happens in this tab, and nothing is uploaded.

What the Regex Tester does

This tool lets you build and check a regular expression interactively. You type the pattern and flags and a sample of text, and it marks every part of the text the pattern matches, with a running count of matches.

Use it while you build a regex to confirm it catches what you intend and nothing more, before the pattern goes into code. The live highlighting shows where it hits and where it misses.

How it works

The tool compiles your pattern and flags into a regular expression using the browser's built-in engine, then runs it against the test string. Each match is wrapped in a highlight, and the total is counted. If the pattern is not valid, the engine's error message is shown instead.

Because it uses the browser, the flavour is ECMAScript, the same regex your JavaScript code would run. Flags control behaviour: g matches all occurrences, i ignores case, m makes the anchors work per line, s lets the dot match newlines, u enables full Unicode, and y anchors matching to a position.

What it checks & how

  1. Read pattern and flags. Take the regular expression and the flags you enter.
  2. Compile the regex. Build it with the browser's engine, showing any error if it is invalid.
  3. Match the test string. Run the pattern against your text and find every match.
  4. Highlight and count. Mark each match in the text and show the total number.

What the flags do

g match all occurrences (not just the first) i ignore case m ^ and $ match per line s dot matches newlines u full Unicode y sticky (match at a fixed position)
Worked example
pattern \b\w+@\w+\.\w+\b on text with two email addresses → 2 matches highlighted

This is the ECMAScript flavour. A pattern that works here matches the same way in JavaScript, but may differ in PCRE, Python or .NET if it uses advanced features.

Privacy

Your pattern and test text stay on your device. The matching runs in your browser with no network request, so nothing is uploaded.

Because the work is local, you can test a pattern against real log lines or sample data without it being stored or sent anywhere.

The tool keeps nothing between sessions: close the tab and the pattern and text are gone.

Standards & references

  • ECMAScript regular expressions: The JavaScript regex flavour, defined in the ECMAScript standard. This tool uses the browser's engine, so its behaviour matches what your JavaScript code will do.
  • Flavour differences: Most basic patterns behave the same everywhere, but advanced syntax differs. JavaScript uses (?) for named groups (not the PCRE (?P)), supports only fixed-width lookbehind, and lacks PCRE features like possessive quantifiers and recursion.
  • Flags: g (global), i (ignore case), m (multiline anchors), s (dot matches newline), u (Unicode) and y (sticky) change how the pattern is applied. The right flags are often as important as the pattern itself.

Accuracy and limits

The matching comes straight from the browser's regex engine, so what you see here is what your JavaScript code will produce.

The flavour is ECMAScript, not PCRE. If your pattern targets PHP, Python, .NET or a database, test it there too: named groups, lookbehind width, and several advanced constructs differ, and a pattern that works here can behave differently elsewhere.

Without the global flag, a regex matches only the first occurrence in code, though this tool highlights all of them for visibility. Keep the g flag in mind when you copy the pattern into your own code, where it changes how methods like match behave.

A complex or poorly written pattern can be slow on large inputs, and certain patterns can backtrack badly (catastrophic backtracking). The tool runs in your browser, so an extreme pattern on a big string may briefly hang the tab.

Where people use it

Building a pattern

Develop and refine a regex with instant visual feedback.

Debugging a match

See what a pattern catches and what it misses.

Validating input formats

Check a pattern for emails, codes or IDs against samples.

Learning regex

Experiment with syntax and flags and watch the effect live.

When it fits, and when it doesn't

Good for

  • Building and testing a JavaScript regex
  • Live match highlighting and counting
  • Checking a pattern against sample text
  • Learning regular-expression syntax

Not the best choice for

  • Patterns targeting PCRE, Python or .NET only
  • Relying on PCRE-only features (recursion, etc.)
  • Extremely large inputs or risky patterns
  • Replacing or transforming text (this only matches)

If your regex runs in PHP, Python or .NET, test it in that engine too, since advanced syntax differs. For find-and-replace rather than just matching, use a tool or editor with a replace field. For very large inputs, run the pattern in your code with proper safeguards.

Frequently asked questions

Which regex flavour does this use?
The JavaScript (ECMAScript) flavour, via the browser's built-in engine. So a pattern that matches here will match the same way in your JavaScript code.
Will my pattern work the same in Python or PHP?
Basic patterns usually do, but advanced syntax differs. Named groups, lookbehind width and several constructs are not identical across ECMAScript, PCRE and Python, so test in the engine your code runs.
What do the flags mean?
g matches all occurrences, i ignores case, m makes the anchors match per line, s lets the dot match newlines, u enables full Unicode, and y makes matching sticky to a position. They change how the pattern is applied.
Why does it highlight all matches without the g flag?
For visibility, the tool shows every match. In code, though, a regex without the global flag matches only the first occurrence, so remember to add g when you copy the pattern if you need all matches.
What happens if my pattern is invalid?
The engine's error message is shown instead of matches. It tells you what is wrong, such as an unbalanced bracket, an invalid escape or a bad flag.
Does it support named capture groups?
Yes, in the JavaScript form using angle-bracket names after a question mark. Note that this differs from the PCRE syntax, so a pattern copied from a PHP example may need adjusting.
Can it do lookbehind?
Yes, fixed-width lookbehind, as JavaScript supports. It does not support the variable-width lookbehind that PCRE allows, so a PCRE pattern relying on that will not work here.
Is my test text uploaded?
No. Your browser runs the match and sends nothing to a server, so you can test against real sample data.
Why is my pattern slow or hanging the page?
Some patterns backtrack heavily on certain inputs (catastrophic backtracking), which can make matching very slow. Simplify the pattern or anchor it more tightly, and avoid running risky patterns on very large text.
Does this replace text or just match it?
It only matches and highlights. For find-and-replace, use a tool or editor that has a replacement field, where you can apply the pattern to transform the text.
What is the difference between match and test?
In code, test returns true or false for whether the pattern matches at all, while match returns the matched text. This tool effectively shows the matches, like a global match with highlighting.
Can I use Unicode property escapes?
With the u flag, JavaScript supports Unicode property escapes. Enable u in the flags and you can match by Unicode category, the same as your JavaScript code would with that flag.

References

Runs your pattern with the browser's JavaScript (ECMAScript) regex engine and highlights matches as you type. Advanced syntax differs from PCRE, Python and other flavours.

PopularHot

JSON Formatter

Pretty-print messy or minified JSON with 2-space indents.

DeveloperOpen
Popular

JSON Validator

Paste JSON and find out whether it parses.

DeveloperOpen
Popular

Base64 Encoder

Standard Base64 for any text, emoji included.

DeveloperOpen
Popular

Hash Generator

MD5, SHA-1 and the SHA-2 hashes of any text, as you type.

DeveloperOpen
Popular

UUID Generator

Up to 500 random version 4 UUIDs at once.

DeveloperOpen
Trending

CSS Minifier

Strips comments and whitespace to put a stylesheet on one line.

DeveloperOpen

Back to the Regex Tester

Paste, run and copy. The code stays in your browser and you don't need an account.