RGX

Regex Cheatsheet

The regex syntax used across JavaScript, Python, and most modern languages - character classes, quantifiers, anchors, and groups.

Character classes

.

Any character except newline

\d

Any digit (0-9)

\D

Any non-digit

\w

Word character (letter, digit, underscore)

\W

Non-word character

\s

Whitespace (space, tab, newline)

[abc]

Any of a, b, or c

[^abc]

Any character except a, b, or c

[a-z]

Any lowercase letter

Quantifiers

*

0 or more of the preceding token

+

1 or more of the preceding token

?

0 or 1 of the preceding token

{n}

Exactly n occurrences

{n,}

n or more occurrences

{n,m}

Between n and m occurrences

Anchors & boundaries

^

Start of string (or line, with m flag)

$

End of string (or line, with m flag)

\b

Word boundary

\B

Not a word boundary

Groups & flags

(abc)

Capture group

(?:abc)

Non-capturing group

(?<name>abc)

Named capture group

a|b

Match a or b

g

Flag: global - find all matches

i

Flag: case-insensitive

m

Flag: multiline - ^ and $ match line boundaries