iToolsPro

正则表达式测试器

在线正则表达式测试器,实时匹配高亮、捕获组展示与替换测试,内置 15+ 常用正则模板

输入
常用模板
正则模式
/ /
标志
测试文本
替换为(可选)
结果
匹配高亮
匹配列表
捕获组
替换结果
Match · Groups · Replace

正则在手,调试无忧

输入正则与测试文本即可实时看到匹配高亮、捕获组详情与替换结果,内置常用模板一键套用。

100% 本地处理 · 纯前端计算

核心特性

实时高亮
输入即匹配,测试文本中的命中区域实时高亮,支持 g/i/m/s/u/y 标志。
捕获组展示
逐条列出每个匹配的编号、命名组与值,方便核对提取逻辑。
替换测试
填写替换字符串即可预览替换结果与替换次数,支持 $1 反向引用。

适用场景

🐛 日志分析 🗂 数据清洗 🎓 正则学习 📝 表单校验

正则表达式测试器使用指南Regex Tester Guide

了解正则表达式测试器的功能、常用模板与常见问题。What this regex tester does, its built-in patterns, and answers to common questions.

功能说明What It Does

正则表达式测试器支持实时匹配高亮、捕获组展示与替换测试,并提供手机号、邮箱、身份证、URL、IP、日期等 15+ 常用模板。

The regex tester provides real-time match highlighting, capture group inspection and replace testing, with 15+ built-in patterns for phones, emails, ID cards, URLs, IPs, dates and more.

支持 g/i/m/s/u/y 六种标志,替换功能支持 $1 反向引用,全程本地处理不上传。

Supports the g/i/m/s/u/y flags, replacement with $1 back-references, all processed locally.

使用步骤How to Use

  1. 在「常用模板」选择预设正则,或自行输入正则模式。Pick a preset from the templates or type your own pattern.
  2. 按需勾选 g/i/m 等标志。Toggle flags such as g/i/m as needed.
  3. 在测试文本中粘贴内容,实时查看高亮与匹配列表。Paste text and watch highlights and matches update live.
  4. 输入替换字符串,预览替换结果。Enter a replacement to preview the result.

常见问题FAQ

Q1. 正则无效时怎么办?Q1. What if my regex is invalid?

模式输入框会变红并提示错误原因,不影响页面其他部分。The pattern box turns red with the error message; the rest of the page keeps working.

Q2. 替换支持反向引用吗?Q2. Does replacement support back-references?

支持,使用 $1、$2… 引用捕获组,如把 (\\d{3})-(\\d{4}) 替换为 $1$2。Yes, use $1, $2… to reference groups, e.g. replace (\\d{3})-(\\d{4}) with $1$2.

Q3. 内容会泄露吗?Q3. Is my text uploaded?

不会,匹配与替换全部在浏览器本地完成。No, matching and replacement happen entirely in your browser.

Q4. 为什么只匹配到第一处?Q4. Why does it only match the first hit?

未勾选 g(全局)标志时默认只匹配第一个,勾选 g 后匹配所有。Without the g (global) flag only the first match is shown; enable g to match all.