所有工具
免费

可搜索、可打印的正则表达式参考手册——字符类、锚点、量词、分组、环视、标志以及现成的匹配模式。免费。

Character classes

12
\d
Any digit, equivalent to [0-9]
\D
Any non-digit character
\w
Word character: letter, digit or underscore
\W
Any non-word character
\s
Any whitespace (space, tab, newline)
\S
Any non-whitespace character
.
Any character except newline
[abc]
Any one of a, b or c
[^abc]
Any character except a, b or c
[a-z]
Any lowercase letter in the range
[A-Za-z0-9]
Any alphanumeric character
[\d\s]
Combine classes inside brackets

Anchors & boundaries

8
^
Start of string (or line in multiline mode)
$
End of string (or line in multiline mode)
\b
Word boundary between \w and \W
\B
Not a word boundary
\A
Start of the entire string (PCRE)
\z
End of the entire string (PCRE)
\Z
End of string, before a trailing newline (PCRE)
\G
Start of the current match attempt (PCRE)

Quantifiers

11
*
Zero or more of the preceding token
+
One or more of the preceding token
?
Zero or one (makes it optional)
{n}
Exactly n repetitions
{n,}
n or more repetitions
{n,m}
Between n and m repetitions
*?
Lazy: zero or more, as few as possible
+?
Lazy: one or more, as few as possible
??
Lazy: optional, prefers zero
{2,5}?
Lazy bounded repetition
a++
Possessive: no backtracking (PCRE)

Groups & backreferences

9
(abc)
Capturing group, stores the match
(?:abc)
Non-capturing group
(?<name>abc)
Named capturing group
(?P<name>abc)
Named group, alternate PCRE syntax
a|b
Alternation: match a or b
(red|blue)
Grouped alternation
\1
Backreference to capturing group 1
\k<name>
Backreference to a named group
$1
Reference group 1 in a replacement

Lookaround

6
(?=abc)
Positive lookahead: followed by abc
(?!abc)
Negative lookahead: not followed by abc
(?<=abc)
Positive lookbehind: preceded by abc
(?<!abc)
Negative lookbehind: not preceded by abc
\d(?=px)
Digit only if followed by px
(?<=\$)\d+
Digits only if preceded by a dollar sign

Flags & modifiers

10
g
Global: find all matches, not just the first
i
Case-insensitive matching
m
Multiline: ^ and $ match line breaks
s
Dotall: . also matches newline
u
Unicode mode (full code points)
x
Extended: ignore whitespace, allow comments
y
Sticky: match from lastIndex (JS)
(?i)
Inline case-insensitive flag (PCRE)
(?im)
Combine inline flags
(?i:abc)
Scoped inline flag for a group

Escapes & special chars

11
\.
Literal dot
\\
Literal backslash
\/
Literal forward slash (in /.../ literals)
\t
Tab character
\n
Newline (line feed)
\r
Carriage return
\f
Form feed
\0
Null character
\xFF
Character by two-digit hex code
\x{00E9}
Unicode code point by hex (PCRE)
\Qabc\E
Quote a literal block (PCRE)

Common token shortcuts

10
[0-9]
Single digit, same as \d
[a-fA-F0-9]
A single hexadecimal digit
\d+
One or more digits (whole number)
\w+
One or more word characters
\s+
One or more whitespace characters
.*
Any run of characters (greedy)
.*?
Any run of characters (lazy)
[^\s]+
One or more non-whitespace characters
\b\w+\b
A whole word
(?:\r\n|\n|\r)
Any line ending

Practical patterns

10
^[\w.+-]+@[\w-]+\.[\w.-]+$
Simple email address
https?:\/\/[^\s]+
HTTP or HTTPS URL
\b(?:\d{1,3}\.){3}\d{1,3}\b
IPv4 address
#?[a-fA-F0-9]{6}\b
Six-digit hex color
\d{4}-\d{2}-\d{2}
Date in YYYY-MM-DD format
\+?\d[\d\s-]{7,}\d
Phone number (loose)
[a-z0-9]+(?:-[a-z0-9]+)*
URL slug (lowercase, hyphens)
^\s+|\s+$
Leading or trailing whitespace (trim)
\s{2,}
Two or more consecutive spaces
<[^>]+>
An HTML tag (naive)

Unicode properties

10
\p{L}
Any kind of letter from any language
\P{L}
Any character that is not a letter
\p{N}
Any kind of numeric character
\p{Lu}
An uppercase letter
\p{Ll}
A lowercase letter
\p{P}
Any punctuation character
\p{Sc}
A currency symbol
\p{Han}
A Han (Chinese) script character
\p{Emoji}
An emoji character (where supported)
\p{Greek}
A character from the Greek script

没有条目匹配“:q”。


关于 Regex 速查表

这份正则表达式速查表是正则语法的简明参考:字符类、锚点和边界、量词、分组和反向引用、环视(lookaround)、标志和修饰符、转义和特殊字符、常用符号缩写、可直接使用的实用模式,以及 Unicode 属性。

正则表达式堪称"写完就忘"语法的代表——这些符号简洁却容易混淆,尤其是先行断言与后行断言、贪婪量词与懒惰量词,以及各种分组形式。每一行都展示一个符号或模式,并配有通俗易懂的说明,解释它匹配什么。

速查表以可以直接复制使用的实用模式收尾,而且和这里的每一份速查表一样,它免费且纯客户端运行:实时搜索、粘性目录、每个符号都可一键复制,还有打印按钮,方便生成纸质正则参考表。

如何使用 Regex 速查表

  1. 浏览各章节,从「字符类」「锚点与边界」到「实用模式」和「Unicode 属性」。
  2. 搜索 lookahead、\d 或 lazy 等符号或概念,即可即时过滤速查表。
  3. 当你需要一个可以直接修改使用的现成表达式时,跳转到「实用模式」章节。
  4. 点击符号或模式,或其复制图标,把它复制到你的代码或正则测试工具中。
  5. 打印速查表——正则语法正是那种值得留一份纸质副本的经典内容。

常见问题

共十个章节:字符类、锚点和边界、量词、分组和反向引用、环视、标志和修饰符、转义和特殊字符、符号缩写、实用模式,以及 Unicode 属性。

有。实用模式章节包含针对常见匹配任务的完整表达式,你可以直接复制修改使用,而不必逐个符号拼装。

有。环视章节并排列出了正向和负向的先行断言与后行断言,并配有说明——这是正则语法中最容易混淆的部分之一。

表中展示的语法是主流引擎广泛共享的核心部分,包括字符类、量词、分组、环视和 Unicode 属性转义。不同引擎的专属扩展会有所差异,遇到不常见的写法请在你的目标语言中测试。

是的,完全免费——可搜索、可打印,并完全在浏览器中渲染。


热门搜索
正则表达式速查表 正则表达式语法 正则字符类 正则先行和后行断言 正则量词列表 正则标志参考 常用正则表达式模式 正则邮箱匹配模式
需要帮助?
使用此工具时遇到问题?请告诉我们的团队。
报告问题

将此免费工具添加到你自己的网站 — 复制并粘贴下面的代码。