实时针对你的文本测试正则表达式。查看每个高亮的匹配,包括捕获组和标志。完全在你的浏览器中运行。
如何使用 正则测试
在模式字段中输入你的正则表达式。
切换你需要的标志(g、i、m、s、u)。
输入测试字符串,查看高亮的匹配及其分组。
The regex tester lets you build and debug regular expressions against your own sample text, with matches highlighted live as you type. It is useful for validating input formats, extracting fields from logs, or testing a pattern before pasting it into code.
Everything runs in your browser, so your patterns and test text are never uploaded.
It uses the JavaScript regular-expression engine, the same one in every browser and in Node.js, so a pattern that works here works in your JavaScript and TypeScript code.
Toggle the global, case-insensitive, multiline and other flags to change how a pattern matches. You see every match along with its capture groups, so you can confirm exactly what each part of the pattern is pulling out.
Other languages such as PCRE, Python and Go share most syntax but differ in some features, so a few advanced constructs may behave differently outside JavaScript. If a pattern works here but not in another language, an engine-specific construct is usually the reason.
常见问题
浏览器内置的 JavaScript(ECMAScript)引擎,因此结果与你的 JavaScript 和 TypeScript 代码一致。
g 匹配所有出现,i 忽略大小写,m 使 ^ 和 $ 在换行处匹配,s 让点号匹配换行,u 启用完整的 Unicode 处理。
启用多行(m)标志,使 ^ 和 $ 在每个换行处匹配;如果你还需要点号匹配换行字符,请加上 dotAll(s)标志。
会。每个匹配都会列出其编号捕获组,命名组按名称显示,因此你能准确看到模式各部分捕获了什么。
这里使用 JavaScript 引擎。PCRE、Python 等共享大部分语法,但在后向断言、命名组和某些转义上有所不同,因此移植高级模式时要小心。
不会。模式和你的测试文本完全在你的浏览器中求值,永远不会离开你的设备。
嵌入此工具
将此工具添加到你自己的网站。复制下方代码片段即可,它会自动保持最新。
<iframe src="https://monu.tools/embed/zh/regex-tester" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>相关工具