Debug flags and capture groups
Compare how m, s, u and y change the behaviour of the same expression in JavaScript.
Guide
The regex tester builds your expression with the browser's JavaScript RegExp directly and supports the six togglable flags g i m s u y. The result area lists match positions, text and numbered or named capture groups, and a replacement box shows the real result of JavaScript String.replace().
Updated 2026-09-102 min read
The regex tester builds your expression with the browser's JavaScript RegExp directly and supports the six togglable flags g i m s u y. The result area lists match positions, text and numbered or named capture groups, and a replacement box shows the real result of JavaScript String.replace().
/ and tick the flags you need.$1, $<name> and the rest follow JavaScript replacement semantics.| Input | Output | Notes |
|---|---|---|
\d+ with g |
Every run of digits | g matches globally |
^a with m |
The a at the start of each line | Multiline anchors |
(a)(b) with $2$1 |
ba |
The replacement uses capture groups |
d flag to obtain capture group indices and falls back automatically on older browsers; this does not change the flags you see.g internally, but if you did not tick g the display still keeps only the first match; the replacement strictly uses your original flags, so without g only the first occurrence is replaced.lastIndex advanced manually to avoid an infinite loop; at most 1000 matches are collected.Compare how m, s, u and y change the behaviour of the same expression in JavaScript.
Test $1 or a named capture replacement locally before putting it into code or an editor batch job.
Because the tool uses the browser's JavaScript RegExp and accepts only the ECMAScript regular expression syntax that runtime supports.
No. They are regular expression samples used to check the shape of a string, not to verify the authenticity or ownership of any number.
The pattern, the test text and the replacement are executed locally in the browser only; nothing is uploaded and nothing is saved.
Updated 2026-09-10
Test regular expressions online with match highlighting, capture groups, replace preview and a cheat sheet
Support line 13812345678, backup 15987654321, landline 010-12345678 does not match.
| # | Position | Matched text | Capture groups |
|---|---|---|---|
| 1 | 13-24 | 13812345678 | — |
| 2 | 33-44 | 15987654321 | — |
Supports reference syntax such as $1, $& and named group captures; without g only the first match is replaced
Click an entry to fill in the pattern and sample text