📋
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
| Pattern | Description |
|---|---|
. | Any character except newline |
\d | Digit (0–9) |
\D | Non-digit |
\w | Word character [a-zA-Z0-9_] |
\W | Non-word character |
\s | Whitespace (space, tab, newline) |
\S | Non-whitespace |
[abc] | Any character in the set |
[^abc] | Any character not in the set |
[a-z] | Character in range |
Quantifiers
| Pattern | Description |
|---|---|
* | 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
| Pattern | Description |
|---|---|
^ | Start of string or line |
$ | End of string or line |
\b | Word boundary |
\B | Non-word boundary |
Groups & References
| Pattern | Description |
|---|---|
(abc) | Capturing group |
(?:abc) | Non-capturing group |
(?=abc) | Positive lookahead |
(?!abc) | Negative lookahead |
a|b | a or b |
\1 | Backreference to group 1 |
Common Patterns
| Pattern | Description |
|---|---|
^[\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.