Regex Tester

Tests a regular expression against sample text, showing matches, capture groups and flags.

100% FreeRuns in your browserBasic

Pattern

JavaScript regex syntax help

Characters and classes

.
any character except line breaks (all of them with the s flag)
\d \w \s
digit, word character [A-Za-z0-9_], whitespace
\D \W \S
the opposite of each
[abc] [^abc] [a-z]
one of, none of, a range
\p{L} \p{N}
Unicode letter / number (needs the u or v flag)
\. \* \\
a literal . * \ (escape special characters)

Anchors and boundaries

^ $
start / end of the text (of each line with the m flag)
\b \B
word boundary / not a word boundary

Quantifiers

* + ?
0 or more, 1 or more, 0 or 1 (greedy)
{n} {n,} {n,m}
exactly n, at least n, n to m
*? +? ??
lazy versions — as few as possible

Groups and lookaround

( … )
capturing group → $1, $2 …
(?<name> … )
named group → $<name>
(?: … )
group without capturing
a|b
a or b
(?= … ) (?! … )
followed by / not followed by
(?<= … ) (?<! … )
preceded by / not preceded by
\1 \k<name>
back-reference to a group

Flags

g
find every match (otherwise only the first)
i m s
ignore case · ^ and $ per line · . matches newlines
u v
Unicode mode (v adds set operations); use one, not both
y d
sticky (match at lastIndex only) · record group indices

Replacement text

$& $1 $<name>
whole match, group 1, named group
$` $'
text before / after the match
$$
a literal $

This is the JavaScript dialect your browser runs. Other engines (PCRE, Python, POSIX grep) differ — for example in possessive quantifiers, inline flags and \A / \z anchors, which JavaScript does not have.

Matches

Runs entirely in your browser. Your input is not uploaded or stored.

How the method works

Match offsets are half-open code-unit ranges
Illustrative method
Match offsets are half-open code-unit rangesThe text a12 b3 in six cells with boundary offsets 0 to 6 beneath. The pattern backslash d plus matches 12 from offset 1 to 3 and 3 from offset 5 to 6.match 1: [1, 3)match 2: [5, 6)a12␠b30123456offsetPattern \d+ with flag g · text “a12 b3”start is included, end is excluded: length = end − start
Pattern \d+ (global) on “a12 b3”: match 1 is “12” at [1, 3) and match 2 is “3” at [5, 6). Offset 3 is the boundary after “2”, so it is excluded; end − start is the match length in UTF-16 code units.

Characters outside the Basic Multilingual Plane, such as most emoji, take two code units, so one emoji moves later offsets by 2. Fixed example values for illustration — not your result.

Tip: Enter any known values to calculate the remaining results.

Designed to run locally in your browser. Tool inputs are not intentionally stored by Zerdly unless stated otherwise.