tooldura

All tools

Regex Tester

Test a regular expression against your text, with live highlighting, capture groups and replace

Mode
//g

About Regex Tester

The Regex Tester runs your pattern against your text as you type and shows you three things at once: every match highlighted where it sits in the text, a numbered list of matches with their position and captured groups, and, in replace mode, the finished result. All six JavaScript flags are there as labelled switches rather than letters you have to remember. Matching runs on a background thread with a time limit, so a pattern that backtracks catastrophically is stopped and explained instead of freezing the page and losing what you had typed.

FreeNo paywalls or tiers
No SignupNothing to create
InstantNo setup, no install
Any DeviceMobile, tablet, desktop

The guide behind this tool

Why a Regex Can Hang: Backtracking and the Patterns That Cause It

One regular expression took Cloudflare's network down for 27 minutes. The shape that causes it is recognisable in seconds once you know what to look for.

8 min read

How to use Regex Tester

  1. 1

    Type your pattern in the expression field; the slashes and flags around it are shown for you.

  2. 2

    Tick the flags you need. Global is on by default, since testing usually means finding every match.

  3. 3

    Paste the text you want to test against, and watch the matches highlight as you type.

  4. 4

    Switch to Replace to preview a substitution, using $1 for the first captured group.

Frequently Asked Questions

JavaScript's own, running in your browser, so what you see here is exactly what your code will do in a browser or in Node. It is not PCRE: JavaScript has no atomic groups, no possessive quantifiers and no recursion, and lookbehind is supported in current browsers but was added late. Patterns copied from PHP, Python or Perl mostly work, but not always.