curly{bits}

Free developer tools. Nothing leaves your browser.

curlybits / Regex Tester

Regex Tester

Write a regular expression and watch it match your text as you type. Every match is highlighted, capture groups (numbered and named) are listed, and the replace preview shows the result. It uses the JavaScript regex engine, the same one in browsers and Node.js.

//
Test string
Matches

      

How to use the Regex Tester

  1. Type your pattern between the slashes. Toggle flags like g (all matches), i (ignore case) and m (multiline).
  2. Paste the text to search in the Test string box. Matches are highlighted in alternating colors.
  3. See each match with its position and capture groups on the right.
  4. Tick Replace to preview a replacement using $1, $<name> or $&.

Regex cheat sheet

.Any character except a line break (add the s flag to include line breaks)
\d \w \sA digit, a word character (letter, digit or _), a whitespace character. Capitals (\D \W \S) mean the opposite.
[abc] [^abc] [a-z]One of a, b or c; anything except them; any lowercase letter
^ $Start and end of the text (or of each line with the m flag)
\bA word boundary
* + ? {2,5}0 or more, 1 or more, optional, between 2 and 5 times. Add ? to make them lazy, e.g. .*?
(…) (?:…) (?<name>…)Capture group, non-capturing group, named group
a|ba or b
(?=…) (?!…) (?<=…) (?<!…)Lookahead, negative lookahead, lookbehind, negative lookbehind

Protected from catastrophic backtracking

Some patterns, such as (a+)+$, can take exponential time on certain inputs and freeze a browser tab. Here, matching runs in a background worker and is stopped after two seconds, with a warning, so the page stays responsive.

JavaScript vs other regex flavors

Most syntax is shared with Python, PHP (PCRE), Java and .NET. Differences to watch: JavaScript has no possessive quantifiers or atomic groups, and inline flags like (?i) are newer and not supported everywhere. Named groups use (?<name>…), which Python writes as (?P<name>…).

Frequently asked questions

Which regex flavor does this use?

JavaScript (ECMAScript), as built into your browser. It matches what you'll get in Chrome, Firefox, Safari, Node.js and Deno.

Why does it only find one match?

Turn on the <b>g</b> (global) flag to find every match instead of just the first.

How do I match across multiple lines?

Use the <b>m</b> flag so <code>^</code> and <code>$</code> match at each line, and the <b>s</b> flag so <code>.</code> also matches line breaks.

Is my text uploaded?

No. Everything runs in your browser.

Add this regex tester to your website

Free for blogs, schools and businesses. Copy the code below and paste it into your page's HTML. The tool works exactly like this one and runs in your visitors' browsers, so nothing is uploaded. Please keep the credit line so others can find it too.

Preview embed ↗