Skip to content

Regex Tester for JavaScript Regular Expressions

Test a JavaScript regular expression: every match, numbered and named groups, replace and split previews. Runs in your browser: nothing is uploaded.

Runs in your browser (background thread)

Everything happens on your device: nothing you paste or type is sent to our server or stored. A share link holds your settings, and your input only if you choose to include it.

Flags: g

Without it, ^ and $ match only at the start and end of the whole text.

u and v read the pattern as code points and allow \p{…} classes; v adds set operations such as [\p{L}--[a-z]]. They can’t be combined.

More options

67 characters · 67 bytes · limit 1 MB

Invoice 1042 issued [match 1: 2026-11-12], due [match 2: 2026-12-12]. Paid on [match 3: 2026-12-01].

3 matches.

Matches

  1. Match 1 at 20: 2026-11-12

    Group 1
    2026
    Group 2
    11
    Group 3
    12
    <year>
    2026
    <month>
    11
    <day>
    12
  2. Match 2 at 36: 2026-12-12

    Group 1
    2026
    Group 2
    12
    Group 3
    12
    <year>
    2026
    <month>
    12
    <day>
    12
  3. Match 3 at 56: 2026-12-01

    Group 1
    2026
    Group 2
    12
    Group 3
    01
    <year>
    2026
    <month>
    12
    <day>
    01

$1 for group 1, $<name> for a named group, $& for the whole match, $$ for a dollar sign.

Result

Invoice 1042 issued 12/11/2026, due 12/12/2026.
Paid on 01/12/2026.
Split preview (13 pieces)
  1. Invoice 1042 issued
  2. 2026
  3. 11
  4. 12
  5. , due
  6. 2026
  7. 12
  8. 12
  9. . Paid on
  10. 2026
  11. 12
  12. 01
  13. .
Matches
3
Capturing groups
3
Flags
g

Method: ECMAScript regular expressions (ECMA-262, 17th edition, 2026) · your browser’s JavaScript engine

Off by default. When on, your input is packed into the part of the link after “#”, which browsers never send to any server; anyone you give the link to will see it.

How it works

Your pattern is compiled by your browser's own JavaScript engine, exactly as new RegExp(pattern, flags) would compile it in your code, so what matches here matches in JavaScript and TypeScript. The rules come from the ECMAScript specification, ECMA-262 (17th edition, 2026). With the g flag the tool lists every match the way String.prototype.matchAll does, stepping one character past an empty match (one code point in u or v mode) so it never loops on the same spot.

The replacement preview runs String.prototype.replace with your replacement text, so group references such as $1 and named ones, $& for the whole match and $$ for a dollar sign mean what they mean in JavaScript. The split preview runs String.prototype.split with the same pattern, including any captured groups, which split inserts between the pieces.

Every run happens in your browser, in a background thread with a one-second budget. A pattern that backtracks catastrophically, such as (a+)+$ on a long line of a's followed by another character, can run for minutes in any engine; here the thread is stopped after one second and you see why, instead of a frozen tab. At most 10,000 matches are listed.

Standards this tool follows

Regex Tester: Test JavaScript Regular Expressions Safely

By FindMySum · Last reviewed

This regex tester shows every match of a JavaScript regular expression in your text as you type: where each match starts, what each capturing group and named group caught, what a replacement would produce and how the text would split. The pattern and the text stay in your browser.

How to use the tool

  1. Type the pattern without the surrounding slashes. The flags you pick appear after the closing slash, so /\d+/g is the pattern \d+ with the g flag.
  2. Paste the text to search into Test text. Matches are marked in alternating colours, and each one is listed with its groups below.
  3. To try a substitution, type a replacement such as $2-$1 or $<day>/$<month>; the result appears under it.
  4. Open Split preview to see what text.split(pattern) would return.

A worked example

The example pattern (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) looks for ISO dates. In the invoice text it finds three: 2026-11-12, 2026-12-12 and 2026-12-01. For the first, group 1 (year) is 2026, group 2 (month) is 11 and group 3 (day) is 12. The replacement $<day>/$<month>/$<year> rewrites each date day-first, so the text reads "issued 12/11/2026". The number 1042 isn't matched, because it has no hyphens after it.

Common mistakes

Forgetting to escape special characters. A dot matches any character, so 1.5 also matches 105. Write 1\.5 to match a literal dot. The same goes for ( ) [ ] { } * + ? ^ $ | \ and /.

Greedy quantifiers that swallow too much. <.+> on <b>bold</b> matches the whole string, because .+ takes as much as it can. Use the lazy form <.+?> or a negated class <[^>]+>.

Expecting ^ and $ to match each line. Without the m flag they only match at the very start and end of the text.

Copying a pattern from another language. Python's (?P<name>…) and PCRE's possessive a++ are syntax errors in JavaScript; the tester reports them so you can rewrite them.

To compare two versions of a text instead of searching one, use the diff checker.

Sources

Frequently Asked Questions

Why does my regex work here but not in Python, PHP or Java?

Each language has its own regex flavour. This tester uses JavaScript's (ECMAScript). PCRE (PHP, many editors) and Python support possessive quantifiers, atomic groups in older versions, conditionals and inline flags like (?i) in the middle of a pattern, which JavaScript doesn't; Python names groups (?P<name>…), and Java's \b and Unicode classes behave slightly differently. Simple patterns are usually portable; check anything with lookbehind, Unicode classes or named groups in the target language.

What do the g, i, m, s, u, v, y and d flags do?

g finds every match instead of the first. i ignores case. m makes ^ and $ match at each line. s lets the dot match line breaks. u reads the pattern as Unicode code points and enables \p{…} classes; v does the same and adds set operations and string properties (the two can't be combined). y only matches exactly where the previous match ended. d records where each group starts and ends.

What is catastrophic backtracking?

When a pattern can match the same text in a huge number of ways, such as nested quantifiers like (a+)+ or (\w+\s?)*, a failing match makes the engine try every combination, and the time doubles with each extra character. On a server this is a denial-of-service risk (ReDoS). Rewrite the pattern so each character can be matched in only one way, for example a+ instead of (a+)+.

Why does an empty match show up as a thin bar?

Patterns such as ^, \b, a lookahead or x* can match zero characters. Those matches have a position but no text, so the tester marks the position with a bar and lists the match with an empty value.

Spotted a wrong result or a bug? Report a problem (the link sends the page address only, never what you entered).

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy