正则表达式测试工具

在线测试正则表达式,实时匹配高亮。支持 g/i/m 标志位,结果显示捕获组。

广告位 — Google AdSense

Regex Tester — Live RegEx Highlighting in Browser

工具介绍

Regular expressions are the Swiss Army knife of text processing. This tool uses the ECMAScript (JavaScript) engine, supports all major flags (g / i / m / s / u / y), and highlights matches in real time. Capture groups are listed below. No IDE needed — paste your pattern and test text to debug instantly.

怎么使用

  1. Type your pattern in the regex box (no / / slashes needed)
  2. Paste your test text below
  3. All matches are highlighted; capture groups appear underneath

常见用例

常见问题

Q: Which engine is used?
A: JavaScript / ECMAScript. Python / Go differ slightly (e.g. Python re supports \A).

Q: Match vs capture group?
A: Match is the whole pattern; capture groups are (...) subpatterns listed below.

Q: Common beginner pitfalls?
A: Forgetting to escape . + * ?; using \d incorrectly in string literals (write \\d).

小贴士

Use non-greedy quantifiers to avoid over-matching: .* → .*?

Look up common patterns (email / URL / IP) in any regex cheatsheet

For complex patterns, add inline comments with (?# comment)