About This Tool

What is 正则表达式测试工具?

A tool for testing regular expressions with real-time matching against test strings. Used for debugging and developing regex patterns for string searching, validation, and text parsing in development workflows.

How to Use

  1. Enter your regex pattern in the top input field.
  2. Enter the test string in the area below.
  3. Matching portions are highlighted in real-time.
  4. Configure flags (case insensitive, multiline, etc.) to adjust matching behavior.

Key Features

  • Real-time regex matching with highlighting
  • Case insensitive, multiline, and dotAll flags
  • Detailed match text, position, and capture group display
  • ECMAScript, RE2, and PCRE2 engine selection

Tips

  • For email validation, use standardized regex patterns rather than simple ones.
  • Capture groups () allow you to extract specific matched portions.
  • Using the ? quantifier performs lazy (non-greedy) matching instead of the default greedy matching.

正则表达式测试工具

实时匹配测试正则表达式

//g

Frequently Asked Questions

ECMAScript、RE2和PCRE2引擎有什么区别?

ECMAScript是JavaScript的标准正则引擎。RE2(Go、Google使用)更快且保证线性时间,但缺少反向引用和前瞻等功能。PCRE2(PHP、Nginx使用)功能最丰富,支持递归、条件模式等。

'g'(全局)标志有什么作用?何时使用?

没有'g'标志时,正则在首次匹配后停止。有'g'时会查找所有匹配。需要查找或替换所有出现时使用'g'。注意:在JavaScript中,将'g'与test()一起使用可能因lastIndex状态产生不一致结果。

如何匹配跨多行的文本?

默认情况下,^和$匹配整个字符串的开头/结尾,.不匹配换行符。启用'm'(多行)标志使^和$匹配行边界。启用's'(dotAll)标志使.也匹配换行字符。


Related Tools