Regex Tester

Try a pattern against real text and see exactly what it catches — and what it misses.

Runs on your deviceDeveloperWorkingNo account needed

What this tool does

Regex Tester compiles the pattern you type using the browser's own RegExp constructor, then runs it across the text in the input box. You write the pattern on its own, without the slashes around it, and the flags are checkboxes rather than letters on the end, so g, i, m, s and u are each set deliberately. A pattern the engine refuses is reported as a notice carrying the engine's own words — "Unterminated group", say — rather than quietly matching nothing, although the result pane goes on showing the last successful run until you correct the pattern and press Run again.

The result pane hands your text back with every match wrapped in a highlight, which is the fastest way to see the misses as well as the hits: a pattern that catches four of the five lines you expected makes that obvious at a glance. Copying the output gives a different view — a numbered list of matches, each with the position it began at and the contents of its capture groups, with named groups printed alongside. Fill in the replacement field and the rewritten text is appended to that list, so $1, $2 and

lt;name> can be checked before the expression goes anywhere near a real file.

Three things are worth weighing before you lean on a run. The first is the flavour: this is the JavaScript engine, so a pattern lifted from Perl, PHP or Python may behave differently or refuse to compile — inline flags such as (?i), atomic groups, possessive quantifiers, recursion and POSIX classes like [:alpha:] are not part of it, and the sticky and indices flags are not offered here at all. The second is that matching runs on the page's own thread with no time limit, so an expression that backtracks catastrophically against a long string will freeze the tab until you reload it. The third is a ceiling: scanning stops after 5,000 matches, which the summary states outright. None of this leaves the machine — pattern and text are handled by the tab you are reading, and neither is sent onwards.

How to use it

  1. Paste the text to run against. Use a sample of the real thing — log lines, a spreadsheet column, an email body. Load sample fills the box with two names, two email addresses and three dates if you only want to try the tool out.
  2. Type the pattern. Top field of the settings panel, JavaScript syntax, no slashes. It starts on (\w+)@([\w.]+), which splits an email address into two capture groups.
  3. Choose the flags. g finds every match and is on by default; switch it off and only the first is reported. i ignores case, m makes ^ and $ meet each line, s lets the dot cross newlines, and u turns on Unicode mode for escapes like \p{L}.
  4. Read the highlights. Matches appear marked in place in the text. The line beneath counts them, adding the number of capture groups when the pattern has any, and repeats the pattern with its flags back at you when nothing matched.
  5. Copy the list, or preview a replacement. Copy output gives you the numbered matches with their offsets and groups. Adding a replacement appends the rewritten text underneath it.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Checking a validation rule before it ships

Paste the awkward inputs — a plus sign in an address, a trailing space, an accented name — and watch which of them the pattern lets through.

Pulling fields out of log lines

Wrap the timestamp and the status code in capture groups, then read them back from the copied list instead of counting characters by hand.

Drafting a search and replace before you run it

Test the substitution here with $1 and $2 in place, then take the working expression to your editor or to Find and Replace.

Working out why a rule never fires

A pattern match that works in one place and not another is usually a flag: case sensitivity, or ^ anchoring to the whole text rather than to each line.

Questions

Does the text I paste in leave the tab?
No. The pattern is compiled and run by the browser's own regular expression engine inside this tab, so neither it nor your text is transmitted, and a run finishes just as well with the machine offline.
Which regex flavour is this?
JavaScript's, exactly as your browser implements it. Patterns written for PCRE, Python or Java often need adjusting: inline flags like (?i), atomic groups, possessive quantifiers and POSIX classes such as [:alpha:] are not JavaScript syntax, and will either fail to compile or mean something else entirely.
Why did the count stop at 5,000?
Scanning stops there on purpose, so that a very broad pattern over a very long text cannot run away with the tab. The summary says when that ceiling was reached, which means a count of 5,000 is at least that many rather than exactly that many. Everything after the 5,000th match comes back unhighlighted, so a clean-looking tail means the scan stopped there, not that the pattern missed it.
Can a pattern lock up the page?
Yes. Matching runs on the page's own thread with no timeout, so an expression prone to catastrophic backtracking — nested quantifiers over a long string, typically — can freeze the tab until you reload. Trim the test text down before experimenting with a pattern you are unsure of.
What is the number next to each match?
Where the match starts, counted in UTF-16 code units from the beginning of the text. That lines up with most editors for ordinary text, but an emoji or another astral character sitting before the match counts as two positions rather than one.
Why does an empty match repeat over and over?
A pattern that can match nothing, such as x*, matches at every position — four times against abc, including once past the final character. A zero-length match has nothing to highlight, so the result pane looks untouched; the count and the copied list are where they surface, as empty quotation marks against their offsets. Seeing them usually means a quantifier should have been + rather than *.
Does the replacement alter my text?
No. It is a preview appended to the copied output, and the original stays untouched in the input box. Worth knowing: the preview always replaces every match, even when the g flag is off, so a first-match-only count can sit above a fully replaced body of text.

Related tools