跳到内容
所有工具

Regex Lab

可用

通过实时匹配、单元测试、精选库、兼容性分析和安全的本地执行来构建、测试、调试和复用正则表达式。

本地运行。测试数据不会离开此浏览器。
//gm
JavaScript / ECMAScript·浏览器原生执行
匹配高亮预览
INFO server ready
WARN retrying request
ERROR upstream timeout
DEBUG hidden diagnostics

正则库

搜索带说明、示例和可直接运行测试的精选模式,并将完整配方加载到工作区。

Practical email address

validation · javascript

Matches a pragmatic email shape for UI validation without pretending to implement the full RFC grammar.

/^[^\s@]+@[^\s@]+\.[^\s@]+$/i
emailformsvalidation

UUID v4

validation · javascript

Matches canonical UUID version 4 strings with the correct version and variant nibble.

/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
uuididentifierapi

ISO date shape

dates · javascript

Matches YYYY-MM-DD text shape. Calendar validity such as leap years still belongs to date parsing.

/\b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b/g
dateisoyyyy-mm-dd

HEX color

validation · javascript

Matches three, four, six or eight digit CSS hexadecimal color values.

/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i
csscolorhexfrontend

Semantic version core

extraction · javascript

Extracts major, minor and patch numbers with optional prerelease and build metadata.

/\b(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<pre>[0-9A-Za-z.-]+))?(?:\+(?<build>[0-9A-Za-z.-]+))?\b/g
semverversionrelease

HTTP(S) URL

web · javascript

Finds HTTP and HTTPS URLs in prose. Use URL parsing for authoritative validation.

/https?:\/\/[^\s<>"]+/gi
urlhttphttpsweb

Key/value log fields

logs · javascript

Extracts simple key=value pairs and exposes key and value as named captures.

/(?<key>[A-Za-z_][\w.-]*)=(?<value>"[^"]*"|[^\s]+)/g
logskey-valueobservability

Log level

logs · javascript

Finds common application log levels as standalone words.

/\b(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\b/gi
logsleveldebugobservability

URL slug

validation · javascript

Matches lowercase URL slugs made of alphanumeric segments separated by single hyphens.

/^[a-z0-9]+(?:-[a-z0-9]+)*$/
slugurlrouting

IPv4 address

validation · javascript

Matches IPv4 octets from 0 to 255 without accepting over-range values.

/^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/
ipnetworkipv4

JWT compact shape

extraction · javascript

Finds strings shaped like a compact three-part JWT/JWS. It does not validate signatures or claims.

/\b[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\b/g
jwttokensecurity

Double quoted string

text · javascript

Extracts double-quoted strings while allowing escaped characters inside them.

/"(?:\\.|[^"\\])*"/g
stringquotesparser

快速参考

搜索常用锚点、字符类、分组、lookaround、量词和操作符。

全部 token

显示 80 个 · 共 80 个 token

\n

Newline character

模式
\r

Carriage return character

模式
\t

Tab character

模式
\0

Null character

模式
\f

Form feed character

模式
\v

Vertical tab character

模式
.

Any character except line terminators unless dotAll is enabled

模式
a|b

Alternation — match either expression

模式
\d

Any digit character

模式
\D

Any non-digit character

模式
\w

Any word character

模式
\W

Any non-word character

模式
\s

Any whitespace character

模式
\S

Any non-whitespace character

模式
[abc]

One character from the set

模式
[^abc]

One character not present in the set

模式
[a-z]

One character inside a range

模式
[a-zA-Z]

One character from multiple ranges

模式
[[:alnum:]]

POSIX letters and digits class

模式pcre2
[[:alpha:]]

POSIX letters class

模式pcre2
[[:digit:]]

POSIX decimal digits class

模式pcre2
[[:space:]]

POSIX whitespace class

模式pcre2
[[:word:]]

POSIX word-character class

模式pcre2
^

Start of input, or start of line in multiline mode

模式
$

End of input, or end of line in multiline mode

模式
\A

Absolute start of string

模式pcre2
\Z

End of string, or before its final line terminator

模式pcre2
\z

Absolute end of string

模式pcre2
\b

Word boundary

模式
\B

Non-word boundary

模式
\G

Start of the current match attempt

模式pcre2
a?

Zero or one occurrence

模式
a*

Zero or more occurrences

模式
a+

One or more occurrences

模式
a{3}

Exactly three occurrences

模式
a{3,}

Three or more occurrences

模式
a{3,6}

Between three and six occurrences

模式
a*?

Lazy quantifier — consume as little as possible

模式
a*+

Possessive quantifier — do not backtrack

模式pcre2
(...)

Capturing group

模式
(?:...)

Non-capturing group

模式
(?<name>...)

Named capturing group

模式javascript
(?P<name>...)

Python-style named capturing group

模式python
(?>...)

Atomic non-capturing group

模式pcre2
(?#...)

Inline comment group

模式pcre2
(?=...)

Positive lookahead assertion

模式
(?!...)

Negative lookahead assertion

模式
(?<=...)

Positive lookbehind assertion

模式
(?<!...)

Negative lookbehind assertion

模式
\1

Match text previously captured by group 1

模式
\k<name>

Match text captured by a named group

模式javascript
\k{name}

PCRE2 named backreference

模式pcre2
\g{-1}

PCRE2 relative numeric backreference

模式pcre2
g

Global matching

标志javascript
m

Multiline anchors

标志
i

Case-insensitive matching

标志
s

Dot matches line terminators

标志
u

Unicode-aware matching

标志javascript
y

Sticky matching from the current lastIndex

标志javascript
x

Ignore pattern whitespace and allow comments

标志pcre2
U

Invert default greediness

标志pcre2
$&

Insert the complete match

替换javascript
$1

Insert capture group 1

替换
$<name>

Insert a named capture group

替换javascript
$$

Insert a literal dollar sign

替换javascript
$`

Insert content before the match

替换javascript
$'

Insert content after the match

替换javascript
${1}

PCRE2 replacement capture group

替换pcre2
\p{Letter}

Match a Unicode property or script category

模式
\P{Letter}

Negated Unicode property or script category

模式
\X

Extended Unicode grapheme sequence

模式pcre2
\R

Unicode newline sequence

模式pcre2
\x20

Character by hexadecimal value

模式
\u{1F600}

Unicode code point escape

模式javascript
\Q...\E

Treat enclosed text as literals

模式pcre2
\K

Reset the reported start of the current match

模式pcre2
(*ACCEPT)

PCRE2 control verb — immediately accept the current match

模式pcre2
(*FAIL)

PCRE2 control verb — force the current match path to fail

模式pcre2
(*SKIP)

PCRE2 control verb — move the next match attempt forward

模式pcre2
(*UTF)

Enable UTF mode in PCRE2

模式pcre2

隔离执行

JavaScript 正则表达式在专用 Web Worker 中运行,并设置严格超时,避免异常模式阻塞 Devary 界面。

面向可移植性设计

选择目标正则风格以检查可移植性问题并生成代码,而不会假装一个引擎等同于所有运行时。

私有工作区

模式、示例、测试和导入的 handoff 仅保存在浏览器内存中,不会发送到 Devary 后端。