Skip to content
ToolsNow
Guides All tools
Developer

Regex tester — match highlighting and capture groups

Test a regular expression against sample text with live match highlighting, capture groups and match positions — plus a cheat sheet for when you forget the syntax.

Runs entirely in your browser — nothing is uploaded.

Test text
0 chars0 words0 lines

Quick reference

\dany digit
\wletter, digit or _
\swhitespace
.any character
*0 or more
+1 or more
?0 or 1
{2,4}between 2 and 4
^start
$end
[abc]one of a, b, c
[^a]not a
(…)capture group
(?:…)group, no capture
a|ba or b
\bword boundary

This uses your browser’s own JavaScript regex engine, so behaviour matches what you will get in JS. Other languages differ — Python, PCRE and Go all have their own quirks around lookbehind, named groups and Unicode.

How to use

  1. Enter a pattern. Without the surrounding slashes — those are shown for you.
  2. Set the flags. g for all matches, i to ignore case, m to make ^ and $ match line ends, s to let . match newlines.
  3. Paste test text. Matches are highlighted in place as you type.
  4. Inspect the matches. The table lists each match, its position, and any capture or named groups.

Questions

Which regex flavour is this?

JavaScript’s, because it runs in your browser. That means what you see here is exactly what you will get in JS. Python, PCRE, Go and .NET differ — particularly around lookbehind, named group syntax and Unicode property escapes.

How do I use capture groups?

Wrap part of the pattern in brackets. Each group appears in the match table as $1, $2 and so on. Use (?:…) when you want grouping without capturing, and (?<name>…) for a named group.

Why does my pattern match nothing with ^ and $?

By default those anchor to the start and end of the whole string, not each line. Turn on the m flag to make them match at every line break.

Why is my pattern so slow?

Nested quantifiers over optional groups — patterns like (a+)+b — can backtrack catastrophically, taking exponential time on a non-matching string. This is a real denial-of-service risk if you run user-supplied patterns on a server. Match count here is capped at 5,000 to keep the page responsive.

Related tools