Tham chiếu
Trang tham chiếu nhanh biểu thức chính quy
Tham chiếu nhanh cú pháp biểu thức chính quy bao gồm ký tự, lượng từ, neo, nhóm và mẫu phổ biến.
Last updated: 2026-08-27
| syntax | category | description |
|---|---|---|
| . | Characters | Any character except newline |
| \d | Characters | Any digit (0-9) |
| \D | Characters | Any non-digit |
| \w | Characters | Any word character (a-z, A-Z, 0-9, _) |
| \W | Characters | Any non-word character |
| \s | Characters | Any whitespace (space, tab, newline) |
| \S | Characters | Any non-whitespace |
| \b | Characters | Word boundary |
| \B | Characters | Non-word boundary |
| [abc] | Characters | Any of a, b, or c |
| [^abc] | Characters | None of a, b, or c |
| [a-z] | Characters | Any lowercase letter |
| [a-zA-Z] | Characters | Any letter |
| * | Quantifiers | 0 or more occurrences |
| + | Quantifiers | 1 or more occurrences |
| ? | Quantifiers | 0 or 1 occurrence (optional) |
| {n} | Quantifiers | Exactly n occurrences |
| {n,} | Quantifiers | At least n occurrences |
| {n,m} | Quantifiers | Between n and m occurrences |
| ^ | Anchors | Start of string |
| $ | Anchors | End of string |
| \A | Anchors | Start of string (absolute) |
| \Z | Anchors | End of string (absolute) |
| (...) | Groups | Capture group |
| (?:...) | Groups | Non-capturing group |
| (?=...) | Groups | Positive lookahead |
| (?!...) | Groups | Negative lookahead |
| (?<=...) | Groups | Positive lookbehind |
| (?<!...) | Groups | Negative lookbehind |
| (?P<name>...) | Groups | Named capture group |
| | | Alternation | OR —match either side |
| \ | Escaping | Escape special character |
| ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ | Common Patterns | Email address |
| ^(https?:\/\/)?[\w.-]+\.[a-zA-Z]{2,}.*$ | Common Patterns | URL |
| ^\d{4}-\d{2}-\d{2}$ | Common Patterns | Date (YYYY-MM-DD) |
| ^\d{3}-\d{3}-\d{4}$ | Common Patterns | US phone number |
| ^\d{16}$ | Common Patterns | Credit card number (16 digits) |
| ^[A-Z]{2}\d{2}[A-Z0-9]{1,30}$ | Common Patterns | IBAN (simplified) |
| ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$ | Common Patterns | Hex color |
| ^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ | Common Patterns | IPv4 address |
| ^[a-z0-9-]+$ | Common Patterns | Slug (kebab-case) |
| i | Flags | Case-insensitive matching |
| g | Flags | Global matching (find all) |
| m | Flags | Multiline mode (^ and $ match line boundaries) |
| s | Flags | Dot matches newline |
| u | Flags | Unicode mode |
| y | Flags | Sticky matching |