KO
📋

Regex Cheatsheet

See the core regex syntax — character classes, quantifiers, anchors, groups, and more — presented as a pattern, description, and example trio for quick reading. Use the search box to filter by keyword while coding, so you can look up the exact syntax you need without leaving your workflow.

Regex Tester

//
Matches: 0

Character Classes

PatternDescription
.Any character except newline
\dDigit (0–9)
\DNon-digit
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Any character in the set
[^abc]Any character not in the set
[a-z]Character in range

Quantifiers

PatternDescription
*Zero or more times
+One or more times
?Zero or one time
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Zero or more, lazy (non-greedy)
+?One or more, lazy

Anchors

PatternDescription
^Start of string or line
$End of string or line
\bWord boundary
\BNon-word boundary

Groups & References

PatternDescription
(abc)Capturing group
(?:abc)Non-capturing group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
a|ba or b
\1Backreference to group 1

Common Patterns

PatternDescription
^[\w.+\-]+@[\w\-]+\.[a-zA-Z]{2,}$Email address
^https?:\/\/[\w\-.]+(?:\.[\w\-.]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]*$URL
^\d{2,3}-\d{3,4}-\d{4}$Korean phone number
^\d{4}-\d{2}-\d{2}$ISO date (YYYY-MM-DD)
^[a-zA-Z0-9]{6,20}$Alphanumeric ID (6–20 chars)
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$Strong password (upper+lower+digit, 8+)
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$HEX color code
^\d{1,3}(\.\d{1,3}){3}$IPv4 address

Related Tools

FAQ

Do I really need to learn regex?
Very useful for programming, data analysis, and text editors. It automates repetitive text tasks like email validation, phone extraction, and log analysis.
What are the most commonly used regex patterns?
Email validation, URL matching, phone number extraction, number extraction (\d+), and whitespace removal (\s+) are the most common.