🔍

首页Home › 开发工具Developer Tools

🔎 正则表达式测试Regexp Tester

在文本上测试 JavaScript 正则:列出全部匹配(位置与分组)或执行替换,边输入边更新;过慢的模式会被自动中止,页面不会卡死。本地处理。Test a JavaScript regular expression on text: list every match (position and groups) or run a replace, updating as you type; a pattern that runs too long is stopped so the page never freezes. Processed locally.

使用说明与常见问题How-to & FAQ

「正则表达式测试」是什么?What is the Regexp Tester tool?

在文本上测试 JavaScript 正则:列出全部匹配(位置与分组)或执行替换,边输入边更新;过慢的模式会被自动中止,页面不会卡死。本地处理。Test a JavaScript regular expression on text: list every match (position and groups) or run a replace, updating as you type; a pattern that runs too long is stopped so the page never freezes. Processed locally.

如何使用「正则表达式测试」?How do I use the Regexp Tester tool?

在「正则表达式测试」中,按需设置「正则」、「标志」、「替换为(可选)」等选项,然后点击「运行」按钮即可。In the Regexp Tester: Set "Pattern", "Flags", "Replace with (optional)", then click "Run".

会上传吗?Is anything uploaded?

不会。正则在浏览器本地的后台线程(Web Worker)里运行。No. The regular expression runs locally in a background thread (Web Worker) in your browser.

为什么提示“灾难性回溯”?Why does it say "catastrophic backtracking"?

有些模式(如 (a+)+$、(x|x)*y)在不匹配时要尝试的组合会指数级增长。本页在后台线程中运行匹配,超过 1.5 秒就中止并提示,页面不会卡死;请改写嵌套量词或加锚点。Some patterns (such as (a+)+$ or (x|x)*y) try an exponential number of combinations when they fail. Matching runs in a background thread and is stopped after 1.5 s with this message, so the page never freezes; rewrite the nested quantifiers or add anchors.

会自动重新运行吗?Does it re-run automatically?

会。修改模式、标志、文本或替换内容后约 0.3 秒自动重新运行;也可以按回车或点“运行”。Yes. It re-runs about 0.3 s after you change the pattern, flags, text or replacement; you can also press Enter or click Run.

结果里的 @ 数字是什么?What is the @ number in the results?

匹配在文本中的起始位置(从 0 开始,按 UTF-16 码元计数,与 JavaScript 的 index 一致),后面列出捕获分组和命名分组。The match's start position in the text (from 0, counted in UTF-16 code units, the same as JavaScript's index), followed by the capture groups and named groups.

有哪些选项可以调整?What options can I adjust?

「正则表达式测试」的设置:「正则」默认 \w+;「标志」默认 g;「替换为(可选)」可留空。每次生成结果都按当前设置处理。Settings in the Regexp Tester — "Pattern" default \w+; "Flags" default g; "Replace with (optional)" optional. The result always uses the current settings.

「正则表达式测试」免费吗?需要注册吗?Is the Regexp Tester free? Do I need an account?

「正则表达式测试」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Regexp Tester is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.

相关工具Related tools

🧩 微信小程序组件说明表WeChat Mini Program Components📡 Curl 转代码Curl to Code🔩 拨码开关计算器DIP Switch Calculator🧾 JSON 格式化校验JSON Formatter & Validator🧪 正则表达式测试Regex Tester⏰ Cron 表达式解析Cron Expression Explainer🔀 YAML JSON 互转YAML to JSON Converter📊 CSV JSON 互转CSV to JSON ConverterⓂ️ Markdown 在线预览Markdown Live Preview🗄️ SQL 格式化/压缩SQL Formatter & Minifier🧵 字符串转义/反转义String Escape / Unescape📰 XML 格式化XML Formatter & Validator

← 全部工具All tools