Regex Tester

Test regular expressions with live highlighting, groups and replace.

//

🔒 Runs entirely in your browser. Nothing you enter is uploaded or stored.

What is the Regex Tester?

A regular expression (regex) is a pattern that describes text, for example "an @ sign with word characters on both sides" or "five digits at the start of a line". Regex is built into almost every language and editor. It is also easy to get subtly wrong, so it pays to test a pattern against real examples before you ship it.

This regex tester uses the JavaScript (ECMAScript) regex engine in your browser. Matches are highlighted as you type, and every match is listed with its position, numbered capture groups and named groups ((?<name>…)). A live replace preview shows the effect of $1, $& and $<name> substitutions. Most patterns behave the same way in Python, Java, PHP (PCRE) and .NET. Lookbehind and possessive quantifiers are where engines differ.

How to use the Regex Tester

  1. Type your pattern between the slashes, without the surrounding / /.
  2. Set flags with the checkboxes: g finds all matches, i ignores case, m makes ^ and $ match at each line.
  3. Paste test text. Matches are highlighted and listed with their capture groups.
  4. Optionally enter a replacement to preview a search-and-replace.

Regex cheat sheet

PatternMeaning
.Any character except a newline (any character with the s flag)
\d \w \sDigit, word character [A-Za-z0-9_], whitespace
[abc] [^abc]One of a, b, c / any character except a, b, c
* + ? {2,5}0 or more, 1 or more, 0 or 1, between 2 and 5
*? +?Lazy versions: match as few as possible
^ $ \bStart, end, word boundary
(…) (?:…) (?<n>…)Capture group, non-capturing group, named group
(?=…) (?!…) (?<=…)Lookahead, negative lookahead, lookbehind

Frequently asked questions

Which regex flavour does this tester use?

JavaScript (ECMAScript 2018 and later), as implemented by your browser. It supports lookbehind, named groups, the s (dotAll) flag and Unicode property escapes such as \p{L} with the u flag.

Why does my pattern only find the first match?

Turn on the g (global) flag. Without it, JavaScript stops after the first match.

Why does the page freeze with some patterns?

Patterns with nested quantifiers such as (a+)+$ can cause "catastrophic backtracking", where the engine tries an exponential number of combinations. Rewrite the pattern to avoid ambiguous repetition.

How do I match a literal dot or bracket?

Escape it with a backslash: \., \[, \(. Inside a character class, most characters such as . are already literal.