| Pattern | Description | Example | |
|---|---|---|---|
. | Any character except newline | a.c → abc, a1c | |
\d | Digit [0-9] | \d+ → 123 | |
\D | Non-digit [^0-9] | — | |
\w | Word character [a-zA-Z0-9_] | \w+ → hello_1 | |
\W | Non-word character [^\w] | — | |
\s | Whitespace [ \t\n\r\f\v] | — | |
\S | Non-whitespace | — | |
[abc] | Any of a, b, or c | [aeiou] → vowels | |
[^abc] | Not a, b, or c | — | |
[a-z] | Character range a to z | — | |
[a-zA-Z] | Any letter | — | |
[0-9] | Any digit (same as \d) | — |
| Pattern | Description | Example | |
|---|---|---|---|
* | 0 or more (greedy) | a* → "", a, aaa | |
+ | 1 or more (greedy) | a+ → a, aaa | |
? | 0 or 1 (optional) | colou?r → color, colour | |
{n} | Exactly n times | \d{3} → 123 | |
{n,} | n or more times | \d{2,} → 12, 123 | |
{n,m} | Between n and m times | \d{2,4} → 12, 1234 | |
*? | 0 or more (lazy) | — | |
+? | 1 or more (lazy) | — | |
?? | 0 or 1 (lazy) | — |
| Pattern | Description | Example | |
|---|---|---|---|
^ | Start of string/line | ^Hello → Hello world | |
$ | End of string/line | world$ → Hello world | |
\b | Word boundary | \bcat\b → cat (not cats) | |
\B | Non-word boundary | — |
| Pattern | Description | Example | |
|---|---|---|---|
(abc) | Capturing group | (\d+)-(\d+) → groups | |
(?:abc) | Non-capturing group | — | |
(?<name>abc) | Named capturing group | (?<year>\d{4}) | |
\1 | Backreference to group 1 | (\w)\1 → aa, bb | |
(a|b) | Alternation (a or b) | cat|dog → cat, dog |
| Pattern | Description | Example | |
|---|---|---|---|
(?=abc) | Positive lookahead | \d(?=px) → 5 in 5px | |
(?!abc) | Negative lookahead | \d(?!px) → 5 in 5em | |
(?<=abc) | Positive lookbehind | (?<=\$)\d+ → 100 in $100 | |
(?<!abc) | Negative lookbehind | — |
| Pattern | Description | Example | |
|---|---|---|---|
g | Global — find all matches | — | |
i | Case-insensitive matching | — | |
m | Multiline — ^ and $ match line boundaries | — | |
s | Dotall — . matches newlines | — | |
u | Unicode support | — | |
y | Sticky — match from lastIndex only | — |
| Pattern | Description | Example | |
|---|---|---|---|
\n | Newline | — | |
\t | Tab | — | |
\r | Carriage return | — | |
\0 | Null character | — | |
\\ | Literal backslash | — | |
\. | Escaped dot (literal .) | — |
| Name | Pattern | Description | |
|---|---|---|---|
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} | Basic email address | ||
| URL | https?:\/\/[\w\-._~:/?#\[\]@!$&'()*+,;=%]+ | HTTP/HTTPS URL | |
| IPv4 | \b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b | IPv4 address | |
| IPv6 | (?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4} | IPv6 address (full form) | |
| Phone (US) | \+?1?[\s.-]?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4} | US phone number | |
| Phone (KR) | 0\d{1,2}[\s.-]?\d{3,4}[\s.-]?\d{4} | Korean phone number | |
| Date (YYYY-MM-DD) | \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) | ISO date format | |
| Time (HH:MM:SS) | (?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)? | 24-hour time | |
| Hex Color | #(?:[0-9a-fA-F]{3}){1,2}\b | CSS hex color | |
| UUID | [0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12} | UUID v1-v5 | |
| HTML Tag | <\/?[a-zA-Z][a-zA-Z0-9]*(?:\s[^>]*)?\/?> | HTML tags | |
| Korean | [가-힣]+ | Korean characters (Hangul) | |
| Japanese | [\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF]+ | Japanese (Hiragana/Katakana/Kanji) | |
| Chinese | [\u4E00-\u9FFF]+ | Chinese characters (CJK Unified) | |
| Whitespace Trim | ^\s+|\s+$ | Leading/trailing whitespace | |
| Duplicate Lines | ^(.*)\n(?=.*\1) | Repeated lines |
Comprehensive regex syntax reference organized by category — character classes, quantifiers, anchors, groups, backreferences, and lookahead/lookbehind. Includes a library of common patterns (email, URL, IP, phone, date, etc.) with one-click copy and direct link to Regex Tester.