Skip to main content

HelpyTools
Converters Dev Tools Design Tools Text Tools
  • JSON
  • Regex
  • Encode
  • JWT
  • Hash
  • JS/CSS
  • package.json
  • Wireframe
  • Keys
  • UUID
  • Epoch
  • Password
  • Bases
  • Cron
  • QR

© 2026 helpytools.com

Regex Tester

Test regular expressions with real-time pattern matching, capture groups, and a quick reference guide.

Pattern
/ /
⮕
Test string
Matches

Enter a pattern and test string to see matches.

Character classes

.Any character except newline
\wWord character [a-zA-Z0-9_]
\WNon-word character
\dDigit [0-9]
\DNon-digit
\sWhitespace (space, tab, newline…)
\SNon-whitespace
\tTab
\nNewline
\rCarriage return
[abc]Character class — any of a, b or c
[^abc]Negated class — anything except a, b, c
[a-z]Range — any lowercase letter
[a-zA-Z]Range — any letter (case-insensitive)

Anchors & boundaries

^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNon-word boundary
\AStart of string (no multiline)
\ZEnd of string (no multiline)

Quantifiers

*0 or more (greedy)
+1 or more (greedy)
?0 or 1 — makes preceding token optional
{n}Exactly n times
{n,}At least n times
{n,m}Between n and m times
*?0 or more (lazy — as few as possible)
+?1 or more (lazy)
??0 or 1 (lazy)

Groups & alternation

(abc)Capturing group — stores match in $1, $2…
(?:abc)Non-capturing group — groups without storing
(?<name>abc)Named capturing group — accessible as $<name>
a|bAlternation — matches a or b
\1Backreference — refers to group 1's match
\k<name>Named backreference

Lookaheads & lookbehinds

(?=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

Flags

gGlobal — find all matches, not just the first
iCase-insensitive — A matches a
mMultiline — ^ and $ match line boundaries
sDotall — . matches newlines too
uUnicode — enables full Unicode matching
ySticky — match only at current position

Examples — click to load

/[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}/gi Email address

Matches standard email addresses. The first part allows word chars, dots, + and -. After @, matches a domain and a 2+ char TLD.

/https?:\/\/(?:www\.)?[-\w]+(?:\.\w+)+(?:\/[-\w%@+.~#?&/=]*)? /gi URL

https? makes the s optional. (?:www\.)? is a non-capturing optional group. The path segment uses [-\w%@+.~#?&/=]* to cover query strings.

/^(?:\+?(\d{1,3})[-.\s]?)?…/gm Phone number (international)

Uses ^/$ anchors with the m flag to match one per line. \+? makes the country code prefix optional.

/^#(?:[0-9a-fA-F]{3}){1,2}$|^#[0-9a-fA-F]{8}$/gm Hex colour

Alternation (|) handles 3-digit, 6-digit and 8-digit (with alpha) hex colours.

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{8,}$/gm Password strength

Four lookaheads enforce rules independently: lowercase, uppercase, digit, special char. .{8,} enforces minimum 8 characters.

/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}…/gm IPv4 address

Each octet matches: 25[0-5] (250–255), 2[0-4]\d (200–249), or [01]?\d\d? (0–199). Repeats {3} times for first three octets.

/(\b\w+\b)(?:\s+\1\b)+/gi Duplicate words

Uses a backreference \1 to detect the same word repeated. The i flag ignores case.

/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/gm ISO date (YYYY-MM-DD)

Months reject 00 and 13+. Days handle 01–09, 10–29, 30–31. Can't validate Feb 30th — that needs code.

Replace examples — click to load

/(\d{2})\/(\d{2})\/(\d{4})/g  →  $3-$1-$2 Reformat date → ISO

Reorders US MM/DD/YYYY dates to ISO YYYY-MM-DD using capture-group backreferences $1–$3.

/(\w+),\s*(\w+)/g  →  $2 $1 Swap “Last, First”

Turns Last, First into First Last by swapping the two capture groups.

/[\w.+-]+@([\w-]+\.[a-zA-Z]{2,})/gi  →  ***@$1 Mask email local-part

Redacts the name before @ while keeping the domain ($1) — handy for sanitising logs.

/(?<user>\w+)@(?<domain>[\w.]+)/g  →  $<domain>/$<user> Named-group reorder

Uses named groups $<user> and $<domain> in the replacement instead of numbers.

Saved tool data