跳到主要内容

正则测试器

UpBox优盒工具箱,免费在线正则测试器,实时高亮全部匹配并列出位置与分组,支持全局、忽略大小写、多行等修饰符。

无需注册 · 数据不上传No sign-up · nothing uploaded

表达式与修饰符Pattern & flags

测试文本Test text

匹配预览Match preview

输入正则与文本后自动高亮匹配
匹配数0
耗时—
输入正则表达式后开始匹配

匹配明细Match details

本工具所有运算在本地浏览器完成,你的文件、文本不会上传到服务器

工具介绍

正则测试器把表达式贴在输入框,测试文本放在左侧,匹配结果会即时高亮,并列出每个匹配的起始位置和捕获分组,省去在控制台反复试错。 Paste the pattern at the top and the text on the left: matches highlight instantly, with each hit’s start position and capture groups listed, so you can skip console trial and error.

支持全局、忽略大小写、多行与点匹配换行四个常用修饰符;空匹配也会安全推进,不会出现死循环。全部计算在本机完成。 Global, ignore-case, multiline and dot-all flags are supported, and zero-length matches advance safely instead of looping forever. Everything runs locally.

  • 实时高亮匹配Live match highlighting
  • 位置与分组明细Positions and capture groups
  • 四种常用修饰符Four common flags
  • 空匹配安全处理Safe zero-length handling
  • 本地运行不上传Runs locally

使用说明

  1. 在顶部输入正则表达式,按需勾选修饰符。Enter the pattern at the top and tick any flags.
  2. 把测试文本粘贴到左栏。Paste the test text on the left.
  3. 匹配会实时高亮,并显示匹配数与耗时。Matches highlight live with counts and timing.
  4. 在“匹配明细”查看位置与分组,可复制。Read positions and groups under Details, then copy.

常见问题

为什么匹配数和我预期不一样?Why is the match count unexpected?
默认开启全局修饰符,会找出所有匹配;只想要第一个可取消“全局”,但这样只高亮首个结果。Global is on by default so every hit is found. Untick it to stop at the first match, which then highlights only that one.
分组显示成什么格式?How are groups shown?
每条明细形如 `#1 [12] abc | $1=x $2=y`,方括号内为起始位置。Each line looks like `#1 [12] abc | $1=x $2=y`, with the start index in brackets.
支持哪些高级语法?Which advanced syntax works?
JavaScript 正则语法,包括命名分组、后行断言(现代浏览器)等;不支持 PCRE 专有写法。JavaScript regex syntax, including named groups and lookbehind in modern browsers. PCRE-only constructs are not supported.
会卡死吗?Can it hang?
匹配数量上限 2000 条,空匹配会强制前进一位,避免零宽表达式造成死循环。Results cap at 2000 matches and zero-length hits force the index forward, preventing infinite loops.
广告位

此处为广告位,可放置你的推广素材

支持图片、文字或 HTML 代码,替换本区块内容即可投放

浏览其他分类