/.*/ Live Regex Testing

正则表达式测试器

Build, test and debug JavaScript regular expressions in real time. Live highlighting, capture groups, replace preview. Supports lookbehind, named groups and Unicode.

/ /

Test string

Highlighted

Replace result

A real-time regex playground in your browser

Build and debug regular expressions interactively. As you type the pattern, the test string is re-evaluated and matches are highlighted instantly. Capture groups (both numbered and named) show up in a side panel with their values for every match. No round-trip to a server, no signup, nothing tracked.

原生 JavaScript 正则表达式

We use the browser's own RegExp engine, which means the patterns you test here will behave exactly the same in your JavaScript code. Modern features are all supported: lookbehind (?<=...), named groups (?<name>...), Unicode property escapes \p{...}, and the s (dotall) flag.

替换模式

Toggle replace mode to preview a regex-based substitution. The replacement supports all the standard $ tokens: $1, $2 for numbered groups, $<name> for named groups, $& for the full match, $` for text before the match, $' for text after, and $$ for a literal dollar sign.

ReDoS 防护

Catastrophic backtracking — patterns like (a+)+$ on long input — can hang any regex engine. We have two safety nets:

隐私

Your patterns and test text never leave the page. The engine is built into your browser. No external library is loaded, no analytics fires when you type, no requests go out.

常见使用场景

常见问题

正则测试器支持哪些功能?
支持实时匹配高亮、捕获组显示、标志位切换(g/i/m/s/u)、替换预览和常用正则模式库。使用 JavaScript 原生正则引擎进行匹配。
正则测试器会上传我的数据吗?
不会。所有正则匹配和替换都在浏览器中使用 JavaScript 完成。您的测试文本和表达式永远不会离开设备。
包含哪些常用正则模式?
提供电子邮件验证、URL 匹配、IP 地址、电话号码、日期格式、HTML 标签、十六进制颜色等常用模式。一键插入即可使用,是学习正则表达式的好帮手。
支持哪些正则语法?
使用 JavaScript(ECMAScript)正则语法,支持所有现代功能包括命名捕获组、前瞻/后顾断言、Unicode 属性等。注意与 PCRE(PHP/Python)有少许语法差异。
正则测试器免费吗?有使用限制吗?
完全免费,没有使用限制。处理在浏览器本地进行,适合测试任何复杂度的正则表达式。非常适合开发者调试和学习正则。

相关工具