Regex Tester|正则表达式测试工具

Regex Tester|正则表达式测试工具

Regex Tester|正则表达式测试工具

在线测试正则表达式匹配效果,支持多行文本、高亮显示所有匹配结果,并查看匹配次数。
Test your regular expressions online, highlight all matches in multi-line text, and see the total match count.

1. 输入正则与测试文本 · Pattern & Test Text
标志位 Flags:
直接输入正则表达式主体,例如:\\d+^[A-Za-z]+$\\b\\w{3}\\b
Just type the pattern body, such as \\d+, ^[A-Za-z]+$ or \\b\\w{3}\\b.

若需匹配反斜杠,请在 JavaScript 字符串中写成 \\\\,在本工具输入框里通常直接写 \\ 即可。
To match a backslash, use \\\\ in JS source code, while typing \\ is usually enough here.
在左侧输入要进行匹配的内容,例如一段文章、日志、JSON 字符串、代码片段等。
Paste or type any content to be tested: articles, logs, JSON strings, code snippets, etc.

点击下方“测试正则表达式”按钮后,将展示匹配次数,并在文本中高亮所有命中的部分。
After clicking “Test Regular Expression”, matches will be counted and highlighted in the text.
3. 正则表达式小贴士 · Regex Tips
  • 基础匹配 · Basic matching:
    \\d 表示数字;\\w 表示字母、数字或下划线; . 表示除换行符外的任意字符(若勾选 s 标志,则包含换行)。
    \\d matches digits, \\w matches word characters, and . matches any character except newline (unless the s flag is set).
  • 数量与边界 · Quantifiers & boundaries:
    + 表示“一个或多个”,* 表示“零个或多个”,? 表示“零个或一个”; {m,n} 表示出现 mn 次。
    ^ 匹配行首,$ 匹配行尾,\\b 匹配单词边界。
    + means “one or more”, * “zero or more”, ? “zero or one”, and {m,n} “between m and n times”. ^ matches start of line, $ end of line, and \\b a word boundary.
  • 分组与选择 · Grouping & alternation:
    使用圆括号 () 进行分组,使用 | 表示“或”。例如:(cat|dog) 匹配 catdog
    Use () to group and | for “or”. For example, (cat|dog) matches either cat or dog.
  • 标志位选择 · Choosing flags:
    一般建议勾选 g 标志以查看所有匹配;需要忽略大小写时勾选 i; 处理多行文本时,可尝试勾选 ms 观察差异。
    For most testing, enable g to find all matches; use i to ignore case; and try m or s when working with multi-line text to see the difference.

说明:本工具仅用于学习、调试与日常文本处理,不会将您的任何文本内容上传到服务器。
Note: This tool is intended for learning, debugging, and everyday text processing. Your input text is not uploaded to any server.