Emergency server help: get in touch

Regex Tester for JavaScript

Test a JavaScript regular expression against sample text and see every match, group and replacement as you type.

Where it runs
Runs in your browser
Last updated
October 9, 2026

In this regex tester, type a pattern, pick the flags and paste some text. The tester highlights every match, lists each one with its position and capture groups (named groups too) and can preview a replacement with $1 or $<name>. It uses your browser’s own JavaScript regex engine, so nothing is uploaded and results match what Node.js and modern browsers do.

Loading the tool… It runs in your browser and needs JavaScript.

How to use the regex tester

Enter the pattern without the surrounding slashes, so \d+ rather than /\d+/. Tick the flags you need, then paste your test text. Matches are highlighted in alternating colours so two matches that touch are still easy to tell apart, and the match list shows the index (the position counted from zero), the matched text and every capture group.

The common pattern buttons fill in ready-made expressions for IPv4 addresses, email addresses, ISO dates, Apache combined log lines and UUIDs. The Apache and ISO date patterns use named groups, so the match list shows fields such as status or year by name.

What the flags mean

  • g (global) finds every match instead of stopping at the first.
  • i ignores case, so error also matches ERROR.
  • m (multiline) makes ^ and $ match at the start and end of every line, which you need for log files.
  • s lets . match new lines as well.
  • u turns on full Unicode mode: emoji count as one character and \p{L} style classes work.
  • y (sticky) only matches at the current position, so matching stops at the first gap.

Replace mode

Turn on replace mode to see the text after String.replace. Use $1, $2 for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign. Without the g flag only the first match is replaced, exactly as in JavaScript.

Slow patterns and the safety limits

Some patterns backtrack so much that a short line can take minutes, for example (a+)+$ against a long run of a characters followed by b. This is known as catastrophic backtracking or ReDoS. The tester runs every match and replace in a background worker, so such a pattern cannot freeze the page: it is stopped after 2 seconds with a clear message, and you can press Cancel sooner. Matching also stops after 10,000 matches, and the test text is limited to 500 KB.

For server admins

JavaScript regex syntax is close to PCRE, which grep -P, PHP and many log tools use, but not identical to POSIX grep -E or sed. Lookbehind, named groups and \d work in grep -P but not in plain grep -E. A quick test on a real log:

grep -P '^(?<ip>\S+) \S+ \S+ \[[^\]]+\] "POST /wp-login\.php' /var/log/apache2/access.log | wc -l

At a glance

Regex Tester – short answer
In short: Test a JavaScript regular expression against sample text and see every match, group and replacement as you type.
Regex Tester – what this tool covers
Regex Tester: what this tool covers.
Regex Tester – questions answered
Regex Tester: the questions this tool answers.

Related: Regex Cheat Sheet: PCRE, JavaScript, Python and grep -E · AI fail2ban Regex Generator: Filters and Jails from Log Lines · Diff Checker: Compare Two Texts.

Official documentation (checked 9 October 2026): MDN: Regular expressions guide · MDN: String.prototype.replace()

Frequently asked questions

Which regex flavour does this tester use?

It uses the JavaScript (ECMAScript) engine built into your browser. Patterns behave the same in Node.js and in browser code, and are close to PCRE, though some PCRE features such as possessive quantifiers are not supported.

Why does my pattern show “Invalid pattern”?

The browser could not compile it. Common causes are an unclosed bracket or group, a quantifier with nothing before it such as a leading *, or a \p{…} class without the u flag.

Is my text sent anywhere?

No. The pattern and the text stay in your browser tab and matching runs locally.

Share this tool

Free website test

Is your website set up right?

Check SSL, security headers, redirects, robots.txt, sitemap, llms.txt and security.txt in one test. It takes about 30 seconds.