Regex Tester & Generator
Write a regular expression, pick your flags, and paste a test string. Matches are highlighted live with position and capture group details. Everything runs in your browser — nothing is sent to a server.
Common patterns
- g
- Global — find all matches, not just the first
- i
- Case-insensitive matching
- m
- Multiline — ^ and $ match line starts/ends
- s
- Dot-all — . also matches newlines
- u
- Unicode — enables full Unicode matching
Valid 2 matches
Match details
Regex quick reference
Character classes
.- Any character except newline (add
sflag to include newlines) \d- Digit — same as
[0-9] \D- Non-digit
\w- Word character —
[a-zA-Z0-9_] \W- Non-word character
\s- Whitespace (space, tab, newline, etc.)
\S- Non-whitespace
[abc]- Any of a, b, or c
[^abc]- Any character except a, b, c
[a-z]- Any character in range a through z
Anchors
^- Start of string (or line with
mflag) $- End of string (or line with
mflag) \b- Word boundary
\B- Non-word boundary
Flags
g- Global — find all matches, not just the first
i- Case-insensitive matching
m- Multiline —
^/$match line starts/ends s- Dot-all —
.also matches\n u- Unicode — enables full Unicode matching
Quantifiers
*- 0 or more (greedy)
+- 1 or more (greedy)
?- 0 or 1 (optional)
{n}- Exactly n times
{n,}- n or more times
{n,m}- Between n and m times
*?+???- Lazy (match as few as possible)
Groups & lookaround
(abc)- Capturing group
(?:abc)- Non-capturing group
(?<name>abc)- Named capturing group
(?=abc)- Positive lookahead — followed by abc
(?!abc)- Negative lookahead — not followed by abc
(?<=abc)- Positive lookbehind — preceded by abc
(?<!abc)- Negative lookbehind — not preceded by abc
a|b- Alternation — match a or b