Regex Tester

Type a regular expression and some test text. Matches light up as you type, capture groups are listed, and you can preview a find-and-replace before using it.

SEO & Web Tools Runs in your browser Free, no sign-up Live highlighting
Matches0Groups0
//

Try:
Matches highlighted
#MatchIndexGroups
Result

How to test a regular expression

  1. Write the patternType it between the slashes, without the slashes themselves, and add flags such as g (all matches) or i (ignore case).
  2. Paste test textMatches are highlighted as you type, in alternating colours so neighbouring matches are easy to tell apart.
  3. Check groups and replaceThe table lists every match, its position and its capture groups. The replace box previews the result using $1, $2 and so on.

The tester uses your browser's JavaScript regex engine, so results match what your code will do in JavaScript and TypeScript. Most patterns also work in Python, PHP and Java with small differences.

Regex cheat sheet

.
Any character except a new line.
\d \w \s
A digit, a word character (letter, digit, underscore), whitespace. Capitals mean the opposite.
* + ? {2,5}
Zero or more, one or more, optional, between 2 and 5 times.
^ $ \b
Start of text (or line), end of text (or line), word boundary.
[abc] [^abc]
Any one of a, b or c; anything except them.
( ) (?: ) (?<name> )
Capture group, non-capturing group, named group.
a|b
Either a or b.

Flags explained

  • g (global): find every match, not just the first.
  • i (ignore case): "Cat" matches "cat" and "CAT".
  • m (multiline): ^ and $ match at the start and end of each line.
  • s (dot all): . also matches new lines.
  • u (unicode): correct handling of emoji and other non-Latin characters.

Tips for reliable patterns

  • Test with bad input too, not only examples that should match.
  • Anchor when validating: ^\d{5}$ checks a whole value; \d{5} finds five digits anywhere.
  • Prefer specific classes such as [^"]* over greedy .*.
  • Don't over-validate emails. A simple pattern plus a confirmation email beats a giant regex; see our email format validator.
  • For simple find-and-replace without regex, use the word finder and replacer.

Frequently asked questions

Which regex flavour does this use?

JavaScript (ECMAScript), as built into your browser. Most common syntax is the same in other languages.

Why does my pattern only find one match?

Add the g flag to find all matches. Without it, only the first match is shown.

How do I use capture groups in the replacement?

Write $1, $2 and so on for numbered groups, or $<name> for named groups.

Is my text sent anywhere?

No. Matching runs entirely in your browser and nothing is uploaded.

More seo & web tools tools