站点名称:A Regex Tester That Shows What the Engine Sees
所属分类:全栈极客与开发辅助
相关标签: # regex tester # regular expressions # regex replace # developer tools
官方网址:https://www.9314.cn/tools/regex-tester/en/
进入网站站点介绍

The usual loop: open the console, write a console.log line, run it, squint at the output. Change one character, do the whole dance again.
The worst part is not a failed match — it is "this should match but shows nothing". Was it a bad escape? A lazy quantifier? A missing flag? You cannot tell.
The preview highlights the hits inside your text. Below it, every match gets a card: what matched, where it starts, and what $1 and $2 captured.
The flag buttons are not decoration. Toggle one and a small line explains what it does — plenty of "almost matching" patterns are just missing the s flag that lets a dot cross a newline.
Replacement lives on the same page. Type $2 $1 and the swapped result appears immediately, no second tool needed.
A pattern like (\d*) matches at every position, and you get a stream of empty hits. This tool does not hide them — empty matches get cards too, with exact positions.
My habit: tighten a quantifier first and watch the count, then toggle flags to watch the scope, and only then look at capture groups. Most "mystery" regex bugs land within those three steps.
Why does my regex match an empty string?Usually a quantifier sits on something optional, like (\d*), which matches at any position. Tighten it to \d+, or check whether a ? applies to a whole group. The tool shows empty matches as they are, with positions, so they are easy to spot.
What does the g flag actually change?Without g you get only the first match of the whole text. With g, the engine scans to the end and every hit gets its own card. Same for the replacement preview: with g everything is replaced, without it only the first occurrence.
Do my pattern and text get uploaded?No. Matching runs on your browser's own regex engine and the page sends no requests. Pattern, text and flags live in this device's localStorage, so they survive a refresh. Use "Clear my data" in the footer to wipe them.
Are lookarounds supported?Yes. (?=...) and (?!...) plus (?<=...) and (?<!...) all work — this is the browser's native engine. Note that Safari before 16.4 lacks lookbehind; use another browser for those.
How does replacement work?Type into the replace box and the full rewritten text appears below. $1 and $2 stand for capture groups; leave it empty to delete matches, or write $2 $1 to swap them.
Tool: Regex Tester: See Every Match as You Type. You may also like the Programmer Calculator.
中文版:https://www.9314.cn/tools/regex-tester/
浏览统计(最近30天)
评论列表 (0条)