Cheatsheet Pages / Regex Cheatsheet

Regex shorthands: \d for digits, \w for word characters, \s for whitespace

Three shorthands cover most everyday matching: digits, word characters, and whitespace.

Patterns use the syntax shared by PCRE / Python / JavaScript; engine differences are flagged in the cheatsheet where they matter. Test any pattern at regex101.com — and pick the matching engine.

Order \d+
# matches "Order 42" — one or more digits
\w+
# matches "user_1", "abc", "007" — stops at spaces and punctuation
Hello\sWorld
# matches "Hello World", "Hello\tWorld"

Good to know

\d is [0-9], \w is [A-Za-z0-9_], and \s covers space, tab and newline. The uppercase version always negates the lowercase one — the rule holds for \D, \W and \S too.

Regex Cheatsheet one-page card — patterns that actually work
The full one-page card — Regex Cheatsheet. Get the complete cheatsheet on GitHub