Developer tools

Regex tester

Test a JavaScript regular expression on your text: every match, its position and capture groups, or a replacement preview.

Regex tester
Esc to restore

Your inputs

JavaScript syntax, for example \b\w+@\w+\.com\b or (?<year>\d{4}). Up to 2,000 characters.

Any of d g i m s u v y. g only matters for replacing; listing matches always finds all of them.

Use $1, $<name>, $& and $$.

Results update as you type. Larger files run when you press Update result.

Your result

Your result will appear here.

More actions

Your inputs stay in this browser. Nothing is uploaded or saved.

A clear answer. Here’s how.

Compiles the pattern with this browser’s JavaScript RegExp engine and walks the text with exec(), recording each match, its start and end offsets (UTF-16 code units from 0), its line and column, and every numbered and named group. Empty matches advance by one character (or one code point with the u or v flag), as String.prototype.matchAll does, and at most 500 matches are listed. The replacement preview uses String.prototype.replace, so $1, $<name>, $& and $$ work as in JavaScript. The search runs in a background worker that is stopped after 3 seconds, so a pattern that backtracks catastrophically cannot freeze the page. JavaScript syntax differs from PCRE, Python and .NET in places, for example in lookbehind support and named-group syntax.

How this is checked

5 reference checks passed These 5 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.

See the checks and where each expected answer comes from
  1. Case 1

    Inputs
    Regular expression (without slashes) (\d{4})-(\d{2})-(\d{2})Flags gShow matchesText to search 2026-10-18 and 2027-01-02
    Expected, and what Toolmoz gave
    Matches found expected 2, Toolmoz 2Capture groups expected 3, Toolmoz 3
    Where the expected answer comes from
    Two ISO dates, each with three capture groups, counted by hand
    Allowed difference
    exact
  2. Case 2

    Inputs
    Regular expression (without slashes) a*Flags gShow matchesText to search baac
    Expected, and what Toolmoz gave
    Matches found expected 4, Toolmoz 4
    Where the expected answer comes from
    ECMAScript semantics: /a*/g on "baac" matches "" at 0, "aa" at 1, "" at 3 and "" at 4
    Allowed difference
    exact
  3. Case 3

    Inputs
    Regular expression (without slashes) (\d{4})-(\d{2})-(\d{2})Flags gShow replaceText to search 2026-10-18 and 2027-01-02Replacement $3/$2/$1
    Expected, and what Toolmoz gave
    text expected 18/10/2026 and 02/01/2027, Toolmoz 18/10/2026 and 02/01/2027Matches found expected 2, Toolmoz 2
    Where the expected answer comes from
    Reordering the groups of each date by hand
    Allowed difference
    exact
  4. Case 4

    Inputs
    Regular expression (without slashes) catFlags giShow matchesText to search Cat cat CAT concatenate
    Expected, and what Toolmoz gave
    Matches found expected 4, Toolmoz 4
    Where the expected answer comes from
    Case-insensitive matches of "cat": Cat, cat, CAT and the cat inside concatenate
    Allowed difference
    exact
  5. Case 5

    Inputs
    Regular expression (without slashes) .Flags guShow matchesText to search a😀b
    Expected, and what Toolmoz gave
    Matches found expected 3, Toolmoz 3
    Where the expected answer comes from
    With the u flag an emoji is one code point, so "a😀b" has three characters (without it, four UTF-16 units)
    Allowed difference
    exact

What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.

See a worked example

Worked example

A fixed demonstration, separate from the values you enter above.

Regular expression (without slashes)
(\d{4})-(\d{2})-(\d{2})
Flags
g
Show
Matches, positions and groups
Text to search
2026-10-18 and 2027-01-02

Example result

Example result
#Line:columnStartEndMatchGroups
11:10102026-10-181: 2026; 2: 10; 3: 18
21:1615252027-01-021: 2027; 2: 01; 3: 02

Uses this browser’s JavaScript (ECMAScript) regular expressions, which differ from PCRE, Python and .NET in places. Start and End are UTF-16 code-unit offsets from 0. Empty matches advance by one character. The search runs in a background worker and is stopped after a few seconds, so a pattern that backtracks without limit cannot freeze the page.