Regex tester
DataEnter the pattern without / delimiters. For an empty pattern, use (?:).
Press Ctrl+Enter (Command+Enter on Mac) to test immediately.
Highlighted matches
Alternating highlights separate adjacent matches. A vertical line marks an empty match.
Loading the example. Your text stays in this browser.
Match details
Positions start at 0; end positions are exclusive. Select a match to inspect its capture groups.
Replacement preview
$& full match $1 numbered group $<name> named group $$ literal $
Your original test text stays unchanged.
Quick reference
.- Any character except line breaks (unless s is on)
\d\w\s- A digit, word character, or whitespace character
[a-z][^a-z]- A character in the range, or outside the range
^$- Start or end of text (each line when m is on)
*+?{2,4}- Zero or more, one or more, optional, or two to four repetitions
(abc)(?<name>abc)- Numbered or named capture group
(?:abc)a|b- A noncapturing group, or either alternative
(?=abc)(?!abc)- Look ahead for a pattern or its absence without consuming it
\b\1- A word boundary, or the text captured by Group 1
Regex tester
Test JavaScript regular expressions against your text. See highlighted matches, inspect numbered and named capture groups, change flags, and preview replacements. Everything runs in your browser; nothing is uploaded.
Is my text uploaded?
No. Patterns, text, matches, and replacements stay in this page. Processing runs in your browser without an account, uploads, or saved history.
Which regex syntax does this use?
The tool uses your browser's JavaScript RegExp engine. Enter a pattern without surrounding slashes, then choose flags below it. PHP, Python, and other engines can use different syntax. Unsupported browser flags are disabled.
How do capture groups work?
Parentheses such as (word) capture part of a match as Group 1. Named groups such as (?<name>word) also give that capture a name. A group that did not participate is shown as Not matched; a group that captured no characters is shown as Empty string. Noncapturing groups such as (?:word) do not appear in the group list.
How do replacements work?
Use $& for the full match, $1 or $2 for numbered captures, $<name> for a named capture, and $$ for a literal dollar sign. An empty replacement removes matches. The global flag replaces every match; without it, only the first match is replaced. The preview does not change your test text.
What do match positions mean?
Positions start at zero and the end position is exclusive. They count UTF-16 code units, as JavaScript does, so some characters take two positions. Empty matches are marked with a vertical line in the preview. Use the Unicode flag to advance over complete code points when matching empty strings.
Why did a pattern stop?
Some patterns take too long because of backtracking. Evaluation runs in a separate browser worker with a time limit, so you can edit the pattern and try again. Results also have size limits. A stopped or truncated run never shows a partial replacement as complete.