All references

Development reference

Regex Cheat Sheet

Search regular expression syntax, character classes, groups, quantifiers, anchors and practical patterns.

34 entries

.

Any character

Character

Matches any character except a newline in most regular expression engines.

Example

a.c

Matches

abc, a-c, a7c

\d

Digit

Character

Matches a decimal digit. Commonly equivalent to [0-9].

Example

\d+

Matches

42 in Order 42

\D

Non-digit

Character

Matches any character that is not a decimal digit.

Example

\D+

Matches

Order in Order 42

\w

Word character

Character

Matches letters, digits and underscore in common JavaScript regular expressions.

Example

\w+

Matches

user_42

\W

Non-word character

Character

Matches a character that is not a letter, digit or underscore.

Example

\W+

Matches

@- in user@-name

\s

Whitespace

Character

Matches whitespace such as spaces, tabs and line breaks.

Example

hello\sworld

Matches

hello world

[abc]

Character set

Character

Matches one character contained in the set.

Example

[aeiou]

Matches

Vowels in developer

[^abc]

Negated character set

Character

Matches one character not contained in the set.

Example

[^0-9]

Matches

Any non-digit character

[a-z]

Character range

Character

Matches one character inside the specified range.

Example

[A-Fa-f0-9]

Matches

A hexadecimal character

*

Zero or more

Quantifier

Matches the previous token zero or more times.

Example

ab*c

Matches

ac, abc, abbbc

+

One or more

Quantifier

Matches the previous token one or more times.

Example

ab+c

Matches

abc, abbbc

?

Zero or one

Quantifier

Makes the previous token optional.

Example

colou?r

Matches

color, colour

{n}

Exact repetition

Quantifier

Matches the previous token exactly n times.

Example

\d{4}

Matches

2026

{n,m}

Repetition range

Quantifier

Matches the previous token between n and m times.

Example

\w{3,10}

Matches

Words from 3 to 10 characters

*?

Lazy quantifier

Quantifier

Matches as few repetitions as possible.

Example

<.*?>

Matches

One HTML-like tag at a time

^

Start anchor

Anchor

Matches the beginning of the input, or a line with multiline mode.

Example

^Error

Matches

A line beginning with Error

$

End anchor

Anchor

Matches the end of the input, or a line with multiline mode.

Example

done$

Matches

A line ending with done

\b

Word boundary

Anchor

Matches the boundary between a word character and a non-word character.

Example

\bcat\b

Matches

cat but not concatenate

(abc)

Capturing group

Group

Groups tokens and captures the matched text.

Example

(\d{4})-(\d{2})-(\d{2})

Matches

2026-07-15

(?:abc)

Non-capturing group

Group

Groups tokens without creating a captured result.

Example

(?:https?)://

Matches

http:// or https://

a|b

Alternation

Group

Matches either the expression on the left or the expression on the right.

Example

cat|dog

Matches

cat or dog

\1

Backreference

Group

Matches the same text captured by an earlier group.

Example

\b(\w+)\s+\1\b

Matches

Repeated words such as the the

(?=abc)

Positive lookahead

Lookaround

Requires the following text to match without consuming it.

Example

\d+(?=px)

Matches

24 in 24px

(?!abc)

Negative lookahead

Lookaround

Requires the following text not to match.

Example

foo(?!bar)

Matches

foo not followed by bar

(?<=abc)

Positive lookbehind

Lookaround

Requires preceding text to match without consuming it.

Example

(?<=\$)\d+

Matches

42 in $42

Lookbehind support depends on the regular expression engine.
g

Global flag

Flag

Finds all matches instead of stopping after the first one.

Example

/cat/g

Matches

Every occurrence of cat

i

Case-insensitive flag

Flag

Ignores letter casing while matching.

Example

/hello/i

Matches

hello, Hello, HELLO

m

Multiline flag

Flag

Makes start and end anchors work for individual lines.

Example

/^error/gm

Matches

Lines beginning with error

s

Dot-all flag

Flag

Allows the dot token to match line terminators.

Example

/start.*end/s

Matches

Text spanning multiple lines

u

Unicode flag

Flag

Enables Unicode-aware regular expression behavior.

Example

/\p{Letter}+/u

Matches

Unicode letter sequences

Email

Simple email pattern

Pattern

Matches many conventional email addresses without attempting full RFC validation.

Example

^[^\s@]+@[^\s@]+\.[^\s@]+$
Use dedicated email verification for production identity workflows.
IPv4

Basic IPv4 pattern

Pattern

Matches four dot-separated groups of one to three digits.

Example

^(?:\d{1,3}\.){3}\d{1,3}$

Matches

192.168.1.1

This simple pattern does not restrict each octet to 0–255.
Hex color

Hexadecimal color

Pattern

Matches three-digit or six-digit hexadecimal CSS colors.

Example

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

Matches

#fff, #1a2b3c

Slug

URL slug

Pattern

Matches lowercase words separated by single hyphens.

Example

^[a-z0-9]+(?:-[a-z0-9]+)*$

Matches

regex-cheat-sheet

Related tool

Test patterns in your browser

Use Regex Tester to try expressions against sample text, inspect matches and experiment with flags.

Open Regex Tester