iToolsPro

Regex Tester

Test regex online with real-time match highlighting, capture group inspection and replace testing, plus 15+ built-in patterns

Input
Presets
Pattern
/ /
Flags
Test text
Replace with (optional)
Output
Highlight
Matches
Capture groups
Replacement
Match · Groups · Replace

Write regex, see it work

Type a pattern and test text to see live highlights, capture groups and replacement results - with one-click presets.

100% local · pure in-browser

Features

Live highlighting
Matches highlight in your text as you type, with the g/i/m/s/u/y flags.
Capture groups
Inspect every match's numbered and named groups to verify your extraction logic.
Replace testing
Preview replacement results and count with $1 back-reference support.

Use cases

🐛 Log analysis 🗂 Data cleaning 🎓 Learning regex 📝 Form validation

正则表达式测试器使用指南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.