开发者工具
正则表达式速查表
带实时测试器的交互式正则表达式参考 — 锚点、字符类、量词、分组、前瞻断言、标志和常用模式
深受 1 万+ 开发者信赖
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
继续探索
您可能喜欢的其他 开发者工具…
JSON格式化工具
使用语法高亮和错误检测格式化、验证和压缩JSON
立即试用
Base64编码/解码
将文本或文件编码为Base64,并将Base64字符串解码为可读文本
立即试用
URL编码/解码
编码和解码URL组件和查询字符串参数
立即试用
UUID生成器
生成随机UUID(v1、v4)或批量生成多个UUID
立即试用
哈希生成器
从文本或文件生成MD5、SHA-1、SHA-256、SHA-512哈希
立即试用
正则表达式测试器
实时匹配高亮测试正则表达式并提取分组
立即试用
JWT解码器
解码和检查JSON Web Token — 查看header、payload并验证签名
立即试用
HTML格式化工具
使用正确缩进和语法高亮格式化和美化HTML代码
立即试用