Regex Tester

Enter a pattern and some text — matches are highlighted as you type.

Your text and files never leave your browser — nothing is sent to a server.

Highlighted matches
Match list
#IndexMatchGroups

$1, $2 refer to numbered groups, $<name> to named groups and $& to the whole match. Without g, only the first match is replaced.

Regex cheat sheet
.Any character except a line break
\dDigit 0–9
\wLetter, digit or underscore
\sSpace, tab or line break
\bWord boundary
^Start of string (or line)
$End of string (or line)
*Previous item 0 or more times
+Previous item 1 or more times
?Previous item is optional
{n,m}Previous item n to m times
[abc]One of a, b or c
[^abc]Any character except a, b or c
(…)Numbered capture group
(?:…)Group without capturing
(?<name>…)Named capture group
a|ba or b
(?=…)Followed by … (lookahead)
(?!…)Not followed by … (negative lookahead)
\1Same text as group 1 again

How to use

  1. Type your regex into “Pattern” and switch on the flags you need (g, i, m…). Pasting /pattern/gi splits off the flags automatically.
  2. Add text to “Test string”. Matches light up on the right, and the table below lists each match’s index and group values.
  3. Enter a replacement such as $1 or $<name> in “Replace with” to preview the result instantly.
  4. New to regex? Click “Insert example” to load an email-matching pattern and tweak it step by step.

FAQ

Which regex flavor does this use?

Your browser’s JavaScript (ECMAScript) engine. Named groups, lookbehind and Unicode property escapes like \p{L} (with the u flag) are supported. Most syntax matches PCRE and Python, but a few features differ.

Can a bad pattern freeze the page?

No. Matching runs in a separate Web Worker and is stopped after 1.5 seconds, and at most 1,000 matches are shown, so long text or catastrophic backtracking will not lock up the page.

Is my text sent to a server?

No. The pattern and text are processed entirely inside your browser.

Related tools

All tools