Regex Tester & Explainer

Test regular expressions with live highlighting and capture group extraction

/ /

Match Highlighting

No matches yet. Enter a pattern and test string to see results.

Match Results

No matches found yet.

Common Patterns Library

Click any pattern to load it into the tester

Email Address

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

URL

https?://(?:www\.)?...

Phone (US)

^\+?1?\s*\(?(\d{3})\)?...

IPv4 Address

^(?:(?:25[0-5]|2[0-4][0-9]...)\.){3}...

Date (YYYY-MM-DD)

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|...)

Hex Color

^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Username (3-16 chars)

^[a-zA-Z0-9_-]{3,16}$

Credit Card

^\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}$

Social Security Number

^\d{3}-\d{2}-\d{4}$

ZIP Code (US)

^\d{5}(?:-\d{4})?$

UUID

^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-...

HTML Tag

<([a-z]+)([^<]+)*(?:>...)

Quick Reference

Character Classes

. Any character except newline
\d Digit [0-9]
\w Word character [a-zA-Z0-9_]
\s Whitespace
[abc] Character set

Quantifiers

* 0 or more
+ 1 or more
? 0 or 1
{n} Exactly n times
{n,m} Between n and m times

Anchors & Groups

^ Start of string
$ End of string
(abc) Capture group
(?:abc) Non-capturing group
a|b Alternation (or)