Search DevTools

Jump to any tool or page

Regex Tester

Write a regular expression and watch it match, live. Groups, positions and flags included.

Pattern

/g
Flags
Samples

Test string

0 chars
0 matches

Matches

Write a pattern to see matches.

Reference

Character classes

.
any character except newline
\d
digit (0–9)
\w
word character (a–z, A–Z, 0–9, _)
\s
whitespace (space, tab, newline)
[abc]
any one of a, b or c
[^abc]
anything except a, b or c

Quantifiers

*
0 or more
+
1 or more
?
0 or 1
{3}
exactly 3
{2,}
2 or more
{1,4}
between 1 and 4

Anchors & boundaries

^
start of string (or line with m)
$
end of string (or line with m)
\b
word boundary
\B
not a word boundary

Groups

(abc)
capture group
(?:abc)
group without capturing
(?<name>abc)
named capture group
a|b
a or b
(?=abc)
followed by abc
(?!abc)
not followed by abc
Developer Utilities

About Regex Tester

Test regular expressions against sample text with live match highlighting and capture-group inspection. Patterns run through the browser's own RegExp engine, so behaviour matches what your JavaScript will do at runtime — including its specific dialect quirks.

Frequently asked questions

Why does my regex work here but not in Python or PCRE?
Regex dialects genuinely differ. JavaScript lacks atomic groups and possessive quantifiers, supports lookbehind only in newer engines, and names groups with (?<name>...) where Python uses (?P<name>...). Python's re.match anchors at the string start while JavaScript's test searches anywhere. Escaping inside character classes and Unicode property support vary too, so a pattern is portable only as far as its features are shared.
What is catastrophic backtracking?
A performance failure where nested quantifiers over overlapping alternatives — the classic (a+)+$ — force the engine through exponentially many combinations before rejecting a non-match. A pattern that is instant on short input can hang for minutes on a slightly longer one. Because JavaScript is single-threaded, a server-side regex on user input becomes a denial-of-service vector, ReDoS. The fix is making alternatives mutually exclusive so only one path can match.
What does the global flag change?
More than most expect. With /g, a RegExp object holds a mutable lastIndex, so consecutive .test() calls on the same object resume from the previous match and appear to alternate true and false on identical input — a well-known bug source when a regex is stored in a module constant. It also makes .match() return all matches as plain strings without capture groups, where the non-global form returns one match with its groups.
Why does . not match newlines?
By default the dot matches any character except line terminators. Use the s (dotAll) flag to include newlines, or [\s\S] where the flag is unavailable. This is distinct from the m (multiline) flag, which does not affect the dot at all — it changes ^ and $ to match at line boundaries rather than only at the start and end of the whole string. The two are frequently confused.
Should I use a regex to parse HTML, JSON, or email addresses?
For HTML and JSON, no — both are nested, recursive grammars, and regular expressions cannot reliably match arbitrarily nested structures. Use a real parser. Email is subtler: the RFC 5322 grammar permits quoted strings and comments that make a fully compliant pattern impractical, so the pragmatic approach is a loose check for an @ with plausible parts either side, then confirm deliverability by sending a verification message.