Regex Lab

Live regex tester with pattern reference & cheatsheet

Live Regex Tester

Common Patterns

Email

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Example: user@example.com

URL

https?:\/\/[\w\-]+(\.[\w\-]+)+[\/\w\-.,@?^=%&:/~+#]*Example: https://example.com/path

Phone (US)

\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}Example: (555) 123-4567

IPv4 Address

\b(?:\d{1,3}\.){3}\d{1,3}\bExample: 192.168.1.1

Date (YYYY-MM-DD)

\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])Example: 2024-01-15

Hex Color

#[0-9a-fA-F]{6}\bExample: #ff5733

Username

[a-zA-Z0-9_]{3,16}Example: user_name123

Password (Strong)

(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}Example: P@ssw0rd!

Cheatsheet

.Any character
\dDigit [0-9]
\wWord char [a-zA-Z0-9_]
\sWhitespace
\DNot digit
\WNot word char
\SNot whitespace
^Start of string
$End of string
\bWord boundary
*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,}n or more
{n,m}Between n and m
[abc]Any of a, b, c
[^abc]Not a, b, c
[a-z]Range
(group)Capture group
(?:group)Non-capturing
a|ba or b
(?=x)Lookahead
(?!x)Negative lookahead