Công cụ Developer

Tài liệu Regex

Tài liệu tham khảo biểu thức chính quy tương tác với trình kiểm tra trực tiếp — anchors, character classes, quantifiers, groups, lookaheads, flags và các mẫu phổ biến

Live Regex Tester
//
Hello World 123
1 match"123" @12
Anchors
Start of string (or line with m flag)
e.g. ^Hello
End of string (or line with m flag)
e.g. world$
Word boundary
e.g. \bword\b
Not a word boundary
e.g. \Bend
Start of string (no multiline)
e.g. \AHello
End of string (no multiline)
e.g. world\Z
Character Classes
Any character except newline
e.g. a.c
Word character [a-zA-Z0-9_]
e.g. \w+
Non-word character
e.g. \W+
Digit [0-9]
e.g. \d{3}
Non-digit
e.g. \D+
Whitespace (space, tab, newline)
e.g. \s+
Non-whitespace
e.g. \S+
Any of a, b, or c
e.g. [aeiou]
Not a, b, or c
e.g. [^0-9]
Character in range a to z
e.g. [a-zA-Z]
Chinese characters (Unicode range)
e.g. [\u4e00-\u9fff]+
Quantifiers
0 or more of a (greedy)
e.g. ab*c
1 or more of a (greedy)
e.g. ab+c
0 or 1 of a (optional)
e.g. colou?r
Exactly 3 of a
e.g. \d{4}
3 or more of a
e.g. \w{3,}
Between 3 and 6 of a
e.g. \d{2,4}
0 or more of a (lazy/non-greedy)
e.g. <.*?>
1 or more of a (lazy)
e.g. \d+?
Groups & Capturing
Capture group
e.g. (\d+)-(\w+)
Non-capturing group
e.g. (?:https?)
Named capture group
e.g. (?<year>\d{4})
Backreference to group 1
e.g. (\w+)\s\1
Positive lookahead
e.g. \d(?=px)
Negative lookahead
e.g. \d(?!em)
Positive lookbehind
e.g. (?<=\$)\d+
Negative lookbehind
e.g. (?<!\$)\d+
a or b (alternation)
e.g. cat|dog
Escape Characters
Newline
e.g. line1\nline2
Tab
e.g. col1\tcol2
Carriage return
e.g. \r\n
Literal dot
e.g. \d+\.\d+
Literal asterisk
e.g. \*important\*
Literal parenthesis
e.g. func\(\)
Flags
Global + case-insensitive
e.g. /hello/gi
Multiline (^ and $ match line start/end)
e.g. /^\w+/m
Dotall (. matches newline too)
e.g. /a.b/s
Unicode (enable Unicode support)
e.g. /\p{L}/u
Unicode sets (advanced, ES2024)
e.g. /[\p{Emoji}]/v
Common Patterns
Email address
e.g. user@example.com
HTTP/HTTPS URL
e.g. https://example.com
Phone number (E.164)
e.g. +12345678901
Date (YYYY-MM-DD)
e.g. 2024-04-01
Hex color (without #)
e.g. ff5733
Password: min 8 chars, 1 uppercase, 1 digit
e.g. Password1
IPv4 address (basic)
e.g. 192.168.1.1
URL slug
e.g. my-blog-post
HTML comment
e.g. <!-- comment -->
CSS hex color with #
e.g. #ff5733
IPv4 address (strict-ish)
e.g. 10.0.0.1
Username (3-16 chars)
e.g. user_name-1

Chưa thấy công cụ bạn cần?

Chúng tôi xây công cụ miễn phí dựa trên phản hồi cộng đồng. Hãy đề xuất tiện ích giúp workflow của bạn!

Regex Cheat Sheet — Free Online Tool | FreeTool