Regex Parser Tester

Test regular expressions with live match highlighting, token-by-token breakdowns, and sample string generation

/ /
0 matches
Matches will be highlighted here.
No matches yet.
  • Pattern explanation will appear here.

                

How To Use

Step 1

Enter Pattern

Type your regex and select relevant flags.

Step 2

Test Live Text

See highlighted matches and capture groups in real time.

Step 3

Interpret and Generate

Review pattern explanation and generate example strings.

FAQ

Does the regex tester support flags like g, i, m, s and u?

Yes. You can toggle global, ignore case, multiline, dotAll, unicode, and sticky flags in the tester.

How does regex explanation work?

The parser reads your pattern token by token and generates plain-language explanations for anchors, classes, groups, and quantifiers.

Can I generate example strings from a regex?

Yes. The sample generator creates a representative string using your current pattern so you can quickly sanity-check intent.

What is the difference between greedy and lazy matching?

A greedy quantifier like .* consumes as much as possible, then backtracks; its lazy twin .*? stops at the first match. On the text say "hi" bye, the pattern "..*" captures the whole line, while ".*?" captures only hi. Greedy is the default - append ? to make any quantifier lazy.

How do capture groups and backreferences work?

Parentheses capture: (\d{4})-(\d{2}) against 2026-09-19 gives group 1 = 2026 and group 2 = 09, and in a replace pattern $1 reuses the captured text. Named groups like (?<year>\d{4}) read better in complex patterns. JavaScript numbers groups by their opening parenthesis, starting at 1 - group 0 is always the whole match.

When do I need the u (Unicode) flag?

Add u whenever the pattern or the text involves non-ASCII characters: it makes \w and \d follow Unicode rules, enables property escapes like \p{L} and \p{Script=Arabic}, and treats emoji as single characters. Without u, a UTF-16 surrogate pair can be split in half by a dot match.

How do ^, $, and the m and s flags interact?

By default ^ and $ anchor the whole string and . skips line breaks. The m (multiline) flag makes ^ and $ match at every line boundary instead, and the s (dotAll) flag lets . cross newlines. A common recipe for log parsing is both flags together: /error.*timeout/gms.

Which regex flavor does this tester use?

It runs the JavaScript engine in your browser, so it follows ECMAScript (ECMA-262) regex semantics - the same engine String.prototype.match uses in production JS. Note the differences from PCRE or Python: JavaScript has no \K or recursion, and lookbehind arrived only in ES2018. Patterns written for Perl or PCRE may need small adjustments.

{-- * External Resources Component(#18 Phase 3b 内容佐证工程) * 工具页「权威引用」区块:RFC / W3C / WHATWG / ECMA / IANA / 官方规范站 / Wikipedia。 * * - 接受 :slug 属性 → 经 config/tool-sources.php 家族矩阵渲染该工具的权威引用 * - slug 未命中映射时不渲染(无权威来源的工具静默跳过) * - 链接 title 保持英文(引用源专名);description 经 * common.resources.descriptions.{key} 本地化,lang 未命中回退英文(线上不裸奔) * - 链接保持 dofollow(rel="noopener noreferrer") * * @param string|null $slug --}}