Converter Web ToolsConverter WebTools

Regex Cheat Sheet — Regular Expression Reference

This regex cheat sheet covers the most common regular-expression tokens — character classes, anchors, quantifiers, groups and lookarounds — used in JavaScript, Python, PHP, Java and most other languages. Keep it handy when writing patterns for search, validation and replacement.

TokenMeaning
.Any character except newline
\dAny digit (0–9)
\DAny non-digit
\wWord character (a–z, A–Z, 0–9, _)
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
^Start of string / line
$End of string / line
*0 or more of the previous
+1 or more of the previous
?0 or 1 (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
[abc]Any one of a, b, c
[^abc]Any character except a, b, c
[a-z]Any character in the range a–z
(…)Capturing group
(?:…)Non-capturing group
(?=…)Positive lookahead
(?!…)Negative lookahead
a|ba or b (alternation)
\bWord boundary
\BNon-word boundary
\\Literal backslash
\.Literal dot

Example

^\d{3}-\d{4}$ matches a phone number like 555-1234: three digits, a hyphen, then four digits, anchored to the whole string.

Related tools & charts