Live Pattern Matching

Regular Expression Tester

Test regular expressions in real-time. See matches, groups, and flags instantly.

/ /

Result

0 matches
No matches

10 Essential Regex Patterns

Copy and use these common patterns. Click any pattern to load it in the tester above.

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

Validates standard email format

URL
^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$

Matches HTTP/HTTPS URLs

Phone Number (E.164)
^\+?[1-9]\d{1,14}$

International phone format (E.164 standard)

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

Min 8 chars: uppercase, lowercase, number, special char

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

ISO 8601 date format

IPv4 Address
^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$

Valid IPv4 addresses (0-255 per octet)

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

CSS hex colors (#RGB or #RRGGBB)

UUID
^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[1-5][a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$

Standard UUID/GUID format (v1-v5)

US ZIP Code
^\d{5}(-\d{4})?$

5-digit or ZIP+4 format

, ')">
HTML Tag
^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$

Basic HTML tag matching (use DOM parser for real HTML)

Regex Cheat Sheet

Character Classes

.Any character (except newline)
\dDigit [0-9]
\DNon-digit
\wWord char [a-zA-Z0-9_]
\WNon-word char
\sWhitespace
\SNon-whitespace
[abc]Any of a, b, or c
[^abc]Not a, b, or c
[a-z]Range a to z

Quantifiers

*0 or more
+1 or more
?0 or 1 (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Non-greedy *
+?Non-greedy +

Anchors & Boundaries

^Start of string/line
$End of string/line
\bWord boundary
\BNon-word boundary

Groups & Lookaround

(abc)Capture group
(?:abc)Non-capture group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
a|bAlternation (or)
\1Backreference

Frequently Asked Questions

What are the basics of regex?

Regular expressions (regex) are patterns used to match character combinations in strings. Key concepts:

  • Literal characters match themselves: cat matches "cat"
  • Special characters have special meaning: . * + ? ^ $ [ ] { } ( ) | \
  • Escape special chars with backslash: \. matches a literal period
What do the flags g, i, m mean?
  • g (global) - Find all matches, not just the first one
  • i (case-insensitive) - Match regardless of case (A = a)
  • m (multiline) - ^ and $ match start/end of each line, not just the string
What's the difference between * and +?

* matches zero or more occurrences (the preceding element is optional)

+ matches one or more occurrences (at least one required)

Example: a* matches "", "a", "aa", "aaa"...

Example: a+ matches "a", "aa", "aaa"... but NOT ""

What are greedy vs non-greedy quantifiers?

Greedy (*, +): Match as much as possible

Non-greedy/Lazy (*?, +?): Match as little as possible

Example with string <div>text</div>:

<.*> (greedy) matches: <div>text</div>

<.*?> (non-greedy) matches: <div>

How do I use regex in JavaScript?
// Create regex
const regex = /pattern/flags;
const regex2 = new RegExp('pattern', 'flags');

// Test if matches
regex.test('string');  // returns true/false

// Find matches
'string'.match(regex);  // returns array or null
'string'.matchAll(regex);  // returns iterator

// Replace
'string'.replace(regex, 'new');

// Split
'string'.split(regex);

Related Tools