xutil.dev
Login

Regular Expression Cheatsheet

Quick reference for regex syntax covering basic patterns, quantifiers, anchors, groups, lookaround, character classes, flags, and common patterns

62 commands

.

Match any single character (except newline)

\

Escape metacharacter

|

Alternation (OR)

\d

Digit [0-9]

\D

Non-digit

\w

Word character [a-zA-Z0-9_]

\W

Non-word character

\s

Whitespace (space, tab, newline)

\S

Non-whitespace character

\n

Newline character

\t

Tab character

*

Match 0 or more times

+

Match 1 or more times

?

Match 0 or 1 time

{n}

Match exactly n times

{n,}

Match n or more times

{n,m}

Match between n and m times

*?

Lazy match (0 or more)

+?

Lazy match (1 or more)

??

Lazy match (0 or 1)

^

Match beginning of line

$

Match end of line

\b

Match word boundary

\B

Match non-word boundary

\A

Match start of string

\Z

Match end of string

(pattern)

Capturing group

(?:pattern)

Non-capturing group

(?<name>pattern)

Named capturing group

\1, \2, ...

Backreference to nth group

\k<name>

Named backreference

(a|b)

Alternation within group

(?=pattern)

Positive lookahead

(?!pattern)

Negative lookahead

(?<=pattern)

Positive lookbehind

(?<!pattern)

Negative lookbehind

[abc]

Match any one character in set

[^abc]

Match any character not in set

[a-z]

Lowercase letters

[A-Z]

Uppercase letters

[0-9]

Digits

[a-zA-Z]

All letters

[a-zA-Z0-9]

Alphanumeric characters

[\s\S]

Any character including newline

g

Global search (all matches)

i

Case-insensitive matching

m

Multiline mode (^ $ match each line)

s

Dotall mode (. matches newline)

u

Unicode mode

x

Extended mode (ignore whitespace)

Email

Email address validation

URL

URL validation

IPv4

IPv4 address validation

Date (YYYY-MM-DD)

Date format validation

Phone (Japan)

Japanese phone number

Phone (US)

US phone number

Password (Strong)

Strong password (8+ chars, mixed)

HTML Tag

Match HTML tag

Hex Color

Hex color code

UUID

UUID validation

Whitespace Trim

Trim leading/trailing whitespace

Duplicate Words

Detect duplicate words