Regex测试器

// 使用实时匹配测试和调试正则表达式

/ / g
0 个匹配
[实时]

实时匹配

输入regex模式或测试字符串时匹配结果即时更新。

[可视化]

可视化结果

匹配的文本在测试字符串中直接用彩色背景高亮显示。

[免费]

模式库

快速插入邮箱、URL、电话号码、IP地址、日期的常用regex模式。

// REGEX

JavaScript RegExp:

Regular expressions (regex) are patterns used to match character combinations in strings. JavaScript supports flags: g (global), i (case-insensitive), m (multiline), s (dotAll), and u (unicode).

Example:

/\\d+/g matches "abc123def456" → ["123", "456"]

Use Cases:

  • >Form validation: email, phone, URL
  • >Text search and replace
  • >Data extraction and web scraping
  • >Log file analysis
  • >Input sanitization

>> FAQ

Q: What is regex?

A: A regular expression is a sequence of characters that defines a search pattern for string matching, searching, and replacing.

Q: What do flags mean?

A: g (global) finds all matches. i ignores case. m (multiline) makes ^ and $ match line starts/ends. s (dotAll) makes . match newlines. u (unicode) enables full Unicode.

Q: What are capture groups?

A: Capture groups are created with parentheses () in a regex pattern to capture matched text for later reference.

Q: Greedy vs lazy matching?

A: Greedy quantifiers (*, +, {n,}) match as much text as possible. Lazy quantifiers (*?, +?, {n,}?) match as little as possible.

Q: Common regex patterns?

A: Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,} | URL: https?://[^\\s]+ | IP: \\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b

// 其他语言

Regex Tester — Base64.sh

Regex测试器 | 免费在线正则表达式测试工具

免费在线regex测试器。实时测试和调试正则表达式,支持匹配高亮、捕获组和常用模式。100%客户端处理。

分享:

X Facebook LinkedIn Reddit

参考资料

我们如何确保结果正确

我们使用以下自动化测试验证此工具。下方保留测试用例的原始名称,便于查看实际断言和复现。

验证方法
对捕获组、全局/忽略大小写和 Unicode 零宽匹配比较结果与索引。
对比依据
JavaScript 原生 RegExp.matchAll。
验证范围
两者使用同一 JS 正则引擎;此项验证页面遍历/展示逻辑,不是第二种正则引擎。
测试源码与用例(点击文件名查看)

这些测试覆盖列出的样本和边界,不代表所有输入都已证明正确。往返测试和使用同一依赖库的检查,不属于独立交叉验证。