Quick reference for regular expression syntax, flags, and common patterns
| . | Any character except newline |
| \d | Digit (0-9) |
| \D | Non-digit |
| \w | Word character (a-z, A-Z, 0-9, _) |
| \W | Non-word character |
| \s | Whitespace (space, tab, newline) |
| \S | Non-whitespace |
| [abc] | Character set — matches a, b, or c |
| [^abc] | Negated set — NOT a, b, or c |
| [a-z] | Character range |
| ^ | Start of string / line |
| $ | End of string / line |
| \b | Word boundary |
| \B | Non-word boundary |
| * | 0 or more |
| + | 1 or more |
| ? | 0 or 1 (optional) |
| {n} | Exactly n times |
| {n,} | n or more times |
| {n,m} | Between n and m times |
| *? | Lazy 0 or more |
| +? | Lazy 1 or more |
| (abc) | Capturing group |
| (?:abc) | Non-capturing group |
| (?=abc) | Positive lookahead |
| (?!abc) | Negative lookahead |
| (?<=abc) | Positive lookbehind |
| (?<!abc) | Negative lookbehind |
| | | Alternation (OR) |
| g | Global — find all matches |
| i | Case-insensitive |
| m | Multiline — ^ and $ per line |
| s | Dotall — . matches newline |
| u | Unicode support |
| ^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$ | Email address |
| ^https?://[^\s]+$ | URL |
| ^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$ | Hex color |
| ^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ | IPv4 address |
| ^\d{4}-\d{2}-\d{2}$ | Date (YYYY-MM-DD) |
| ^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$ | Strong password |