Programming · Cheatsheet
Regular Expressions Cheatsheet
JavaScript-style regex syntax, character classes, quantifiers, groups, assertions, flags, and example shape patterns.
44 commands 8 sections
No entry matches that filter.
-
.Any character except newline -
\dAny digit [0-9] -
\DAny non-digit [^0-9] -
\wAny word character [a-zA-Z0-9_] -
\WAny non-word character -
\sAny whitespace (space, tab, newline) -
\SAny non-whitespace -
[abc]Match a, b, or c -
[^abc]Match anything except a, b, or c -
[a-z]Match any lowercase letter -
[0-9]Match any digit
-
*Zero or more times -
+One or more times -
?Zero or one time (optional) -
{3}Exactly 3 times -
{3,}3 or more times -
{3,5}Between 3 and 5 times -
*?Zero or more (lazy/non-greedy) -
+?One or more (lazy/non-greedy)
-
^Start of string (or line with m flag) -
$End of string (or line with m flag) -
\bWord boundary -
\BNon-word boundary
-
(abc)Capturing group -
(?:abc)Non-capturing group -
(?<name>abc)Named capturing group -
\1Back-reference to group 1 -
(a|b)Match a or b (alternation)
-
(?=abc)Positive lookahead (followed by abc) -
(?!abc)Negative lookahead (not followed by abc) -
(?<=abc)Positive lookbehind (preceded by abc) -
(?<!abc)Negative lookbehind (not preceded by abc)
-
gGlobal search (find all matches) -
iCase-insensitive search -
mMulti-line mode (^ and $ match line boundaries) -
sDotall mode (. matches newlines) -
uUnicode mode
-
^[\w.-]+@[\w.-]+\.\w{2,}$Email address (basic) -
^https?://[\w.-]+(?:/\S*)?$URL (basic) -
^\d{1,3}(\.\d{1,3}){3}$IPv4-shaped text only; also matches invalid values such as 999.999.999.999 -
^\d{4}-\d{2}-\d{2}$Date-shaped text only; also matches invalid values such as 2026-99-99 -
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Hex color code -
^\+?\d{10,15}$Phone number (basic international)
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressionsMDN JavaScript RegExp guide: syntax, assertions, flags, and engine-specific behavior.
Related cheatsheets
Guides that use these commands
Tools for this work
- Font Icon SearchSearch icons from FontAwesome, Material Icons, Lucide, and Heroicons by name or keyword. Find the perfect icon instantly.
- Regex TesterTest and debug regular expressions with real-time matching.
- Text Find & ReplaceFind and replace text with regex support, case sensitivity, whole word matching, and live match highlighting.