RX?Regex Cheatsheet
Searchable regex reference: metacharacters, quantifiers, groups, flags, and common patterns (email, URL, phone, IP, UUID)
Basic Metacharacters
| Pattern | Description | Example | |
|---|---|---|---|
| . | Any char except newline | a.c | |
| ^ | Start of line/string | ^Hello | |
| $ | End of line/string | end$ | |
| \\ | Literal backslash | - | |
| | | OR (a or b) | cat|dog |
Quantifiers
| Pattern | Description | Example | |
|---|---|---|---|
| * | 0 or more | ab*c | |
| + | 1 or more | ab+c | |
| ? | 0 or 1 (optional) | colou?r | |
| {n} | Exactly n | a{3} | |
| {n,} | n or more | a{2,} | |
| {n,m} | Between n and m | a{2,4} | |
| *? | 0+ lazy | a.*?b | |
| +? | 1+ lazy | - |
Character Classes
| Pattern | Description | Example | |
|---|---|---|---|
| [abc] | a, b, or c | - | |
| [^abc] | Not a, b, or c | - | |
| [a-z] | Lowercase range | - | |
| [A-Z] | Uppercase range | - | |
| [0-9] | Digit range | - | |
| \d | Digit [0-9] | - | |
| \D | Non-digit | - | |
| \w | Word char | - | |
| \W | Non-word char | - | |
| \s | Whitespace | - | |
| \S | Non-whitespace | - | |
| \b | Word boundary | - | |
| \B | Non-word boundary | - |
Groups & References
| Pattern | Description | Example | |
|---|---|---|---|
| (...) | Capture group | (\d+) | |
| (?:...) | Non-capture group | - | |
| (?<name>...) | Named group | (?<year>\d{4}) | |
| \1 | Backreference to group 1 | - | |
| (?=...) | Positive lookahead | foo(?=bar) | |
| (?!...) | Negative lookahead | foo(?!bar) | |
| (?<=...) | Positive lookbehind | - | |
| (?<!...) | Negative lookbehind | - |
Flags
| Pattern | Description | Example | |
|---|---|---|---|
| g | Global - all matches | - | |
| i | Case-insensitive | - | |
| m | Multiline - ^$ per line | - | |
| s | DotAll - . matches newline | - | |
| u | Unicode mode | - | |
| y | Sticky - from lastIndex | - |
Common Patterns
^[\w.+-]+@[\w-]+\.[\w.-]+$
Example: user@example.com
URL (HTTP/HTTPS)
^https?://[\w.-]+(?:/[^\s]*)?$
Example: https://example.com/path
KR Mobile Phone
^01[016789]-?\d{3,4}-?\d{4}$
Example: 010-1234-5678
IPv4 Address
^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$
Example: 192.168.1.1
IPv6 (simple)
^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$
Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Date YYYY-MM-DD
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Example: 2024-12-31
Time HH:MM (24h)
^([01]\d|2[0-3]):[0-5]\d$
Example: 14:30
Hex Color
^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
Example: #3b82f6
Korean (syllables)
[\uAC00-\uD7A3]+
Example: 안녕하세요
KR ID Number (simple)
^\d{6}-[1-4]\d{6}$
Example: 990101-1234567
Password (strong: A-z, 0-9, symbol, 8+)
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{8,}$
Example: Passw0rd!
Credit Card (16 digits)
^(?:\d{4}[ -]?){3}\d{4}$
Example: 4111-1111-1111-1111
KR Business Number
^\d{3}-\d{2}-\d{5}$
Example: 123-45-67890
KR Postal Code (5 digits)
^\d{5}$
Example: 06236
UUID v4
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
Example: 550e8400-e29b-41d4-a716-446655440000
Integer
^-?\d+$
Example: -42
Float / Decimal
^-?\d+(\.\d+)?$
Example: -3.14
Empty line
^\s*$
Example: (blank line)
HTML tag
<\/?[a-z][\s\S]*?>
Example: <div class="x">
Slug (URL-friendly)
^[a-z0-9]+(?:-[a-z0-9]+)*$
Example: hello-world-123
What is the Regex Cheatsheet?
Regular expressions have a dense syntax that is easy to forget. This cheatsheet collects metacharacters, quantifiers, character classes, groups, and flags in one place — plus a copy-ready library of real-world patterns (email, URL, phone, IP, date, UUID, and more). Use the search box to filter everything instantly.
For live matching, pair it with the regex-tester tool.