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通过实时匹配、单元测试、精选库、兼容性分析和安全的本地执行来构建、测试、调试和复用正则表达式。
INFO server ready WARN retrying request ERROR upstream timeout DEBUG hidden diagnostics
搜索带说明、示例和可直接运行测试的精选模式,并将完整配方加载到工作区。
validation · javascript
Matches a pragmatic email shape for UI validation without pretending to implement the full RFC grammar.
/^[^\s@]+@[^\s@]+\.[^\s@]+$/ivalidation · 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}$/idates · 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/gvalidation · 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})$/iextraction · 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/gweb · javascript
Finds HTTP and HTTPS URLs in prose. Use URL parsing for authoritative validation.
/https?:\/\/[^\s<>"]+/gilogs · javascript
Extracts simple key=value pairs and exposes key and value as named captures.
/(?<key>[A-Za-z_][\w.-]*)=(?<value>"[^"]*"|[^\s]+)/glogs · javascript
Finds common application log levels as standalone words.
/\b(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\b/givalidation · javascript
Matches lowercase URL slugs made of alphanumeric segments separated by single hyphens.
/^[a-z0-9]+(?:-[a-z0-9]+)*$/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)$/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/gtext · javascript
Extracts double-quoted strings while allowing escaped characters inside them.
/"(?:\\.|[^"\\])*"/g搜索常用锚点、字符类、分组、lookaround、量词和操作符。
显示 80 个 · 共 80 个 token
\nNewline character
\rCarriage return character
\tTab character
\0Null character
\fForm feed character
\vVertical tab character
.Any character except line terminators unless dotAll is enabled
a|bAlternation — match either expression
\dAny digit character
\DAny non-digit character
\wAny word character
\WAny non-word character
\sAny whitespace character
\SAny 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
[[:alpha:]]POSIX letters class
[[:digit:]]POSIX decimal digits class
[[:space:]]POSIX whitespace class
[[:word:]]POSIX word-character class
^Start of input, or start of line in multiline mode
$End of input, or end of line in multiline mode
\AAbsolute start of string
\ZEnd of string, or before its final line terminator
\zAbsolute end of string
\bWord boundary
\BNon-word boundary
\GStart of the current match attempt
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
(...) Capturing group
(?:...)Non-capturing group
(?<name>...)Named capturing group
(?P<name>...)Python-style named capturing group
(?>...)Atomic non-capturing group
(?#...)Inline comment group
(?=...)Positive lookahead assertion
(?!...)Negative lookahead assertion
(?<=...)Positive lookbehind assertion
(?<!...)Negative lookbehind assertion
\1Match text previously captured by group 1
\k<name>Match text captured by a named group
\k{name}PCRE2 named backreference
\g{-1}PCRE2 relative numeric backreference
gGlobal matching
mMultiline anchors
iCase-insensitive matching
sDot matches line terminators
uUnicode-aware matching
ySticky matching from the current lastIndex
xIgnore pattern whitespace and allow comments
UInvert default greediness
$&Insert the complete match
$1Insert capture group 1
$<name>Insert a named capture group
$$Insert a literal dollar sign
$`Insert content before the match
$'Insert content after the match
${1}PCRE2 replacement capture group
\p{Letter}Match a Unicode property or script category
\P{Letter}Negated Unicode property or script category
\XExtended Unicode grapheme sequence
\RUnicode newline sequence
\x20Character by hexadecimal value
\u{1F600}Unicode code point escape
\Q...\ETreat enclosed text as literals
\KReset the reported start of the current match
(*ACCEPT)PCRE2 control verb — immediately accept the current match
(*FAIL)PCRE2 control verb — force the current match path to fail
(*SKIP)PCRE2 control verb — move the next match attempt forward
(*UTF)Enable UTF mode in PCRE2
JavaScript 正则表达式在专用 Web Worker 中运行,并设置严格超时,避免异常模式阻塞 Devary 界面。
选择目标正则风格以检查可移植性问题并生成代码,而不会假装一个引擎等同于所有运行时。
模式、示例、测试和导入的 handoff 仅保存在浏览器内存中,不会发送到 Devary 后端。
实用指南
Regex Lab 在浏览器中使用 JavaScript 正则表达式引擎匹配示例文本。本指南介绍如何查看命名捕获组、编写可重复运行的测试,以及在项目中使用表达式前检查跨语言兼容性。
要真正执行匹配,请选择 JavaScript / ECMAScript,并使用 Match 模式查看结果。其他目标引擎仅提供兼容性分析,不会在相应运行时中执行表达式。
输入不带两侧斜杠的表达式,选择 g(匹配所有结果)或 m(按行处理锚点)等标志,再粘贴有代表性的文本。查看高亮结果和捕获组。
在 Unit Tests 中添加应匹配和不应匹配的用例。每次修改表达式后重新运行测试,确认行为符合预期。
在 Match 模式中粘贴两行日志,并使用 gm 标志。命名捕获组 level 和 message 分别提取字段;下方结果由 Regex Lab 的实际 JavaScript 引擎计算。
(?<level>INFO|WARN|ERROR)\s+(?<message>.+)gmINFO server ready
ERROR upstream timeoutINFO: server ready
ERROR: upstream timeout在 Unit Tests 中将每行分别添加为一个用例。第一行应匹配,第二行不应匹配。首尾锚点要求输入带 #,i 标志允许大写字母。✓ 表示匹配,✗ 表示不匹配。
^#[0-9a-f]{6}$i#0ea5e9
0ea5e9#0ea5e9 → ✓
0ea5e9 → ✗实际匹配由浏览器 Worker 中的 ECMAScript RegExp 引擎执行,并设有超时限制。同一表达式在其他语言中可能有不同表现。
PCRE2、Python、Java、.NET、Go 和 Rust 目标只提供静态检查和代码示例,不执行其原生引擎。请务必在目标运行环境中测试。
隔离 Worker 能防止缓慢表达式卡住本页面,但不能证明表达式在生产环境中安全。请使用较长和具有对抗性的输入检查过度回溯。
表达式和示例文本在本地处理,不会上传至 Devary 后端。复制、导出或粘贴到其他服务属于用户独立执行的操作。
不带 g 时,JavaScript 通常只返回第一个匹配项。使用 g 后,Regex Lab 会持续收集匹配项及其捕获组,直到文本末尾。
不会。Python 在此仅作为分析目标。Regex Lab 会提示潜在差异并生成示例代码,但仍需使用 Python 的 re 模块实际运行并验证。
不能。风险启发式检查和 Worker 超时有助于实验,但仍须在部署环境中验证正确性、资源消耗和输入处理。