Skip to content

Test regular expressions

Test a JavaScript regular expression against your text with live match highlighting, capture groups and a plain-English explanation, right in your browser.

JavaScript (ECMAScript) regex flavorThe same engine as your browser, Node.js and Deno
//g

$1 or $<name> insert a group, $& the whole match, $` and $' the text before and after, $$ a dollar sign.

Matches and capture groups appear here.

Runs in your browser · no uploadHow it works

How to use Regex tester

  1. 1

    Enter a pattern

    Type the regular expression without slashes; the flags go in the toggles below it.

  2. 2

    Add a test string

    Paste the text to search; matches are highlighted and listed with their capture groups as you type.

  3. 3

    Check the explanation

    Open Explanation to read each token in plain English and spot what the pattern really does.

  4. 4

    Preview a replacement

    Type a replacement using $1 or $<name> to see the result, then copy the code from the Code tab.

Limits and Pro

Free with no sign-up: up to 100,000 matches counted, 2,000 highlighted and 200 listed in the table; highlighting covers test strings up to 200,000 characters, and each run is stopped after 1.5 seconds.

Pro removes the ads; the tester behaves the same on every plan. See Pro

About Regex tester

This tester runs your pattern with the JavaScript (ECMAScript) regular-expression engine built into the browser — the same one used by Node.js, Deno, Bun and every web page — so what matches here matches in your code. Type a pattern and a test string and every match is highlighted as you type, with a table of positions, numbered capture groups and named groups, and the start and end of each group when the d flag is on.

All eight flags can be toggled: g for every match, i to ignore case, m so ^ and $ work per line, s so the dot also matches line breaks, u for full Unicode and \p{…} property escapes, v for Unicode sets with intersection and subtraction inside brackets, y for sticky matching and d for indices. The replace box previews String.prototype.replace with $1, $<name>, $& and the other substitution tokens, and the Code tab gives the matching literal, matchAll and RegExp() snippets.

The explanation tab breaks the pattern into tokens and says in plain English what each one does — groups, lookarounds, character classes, quantifiers and whether they are greedy or lazy — and the cheat sheet inserts common tokens at the cursor.

Matching runs in a background Web Worker with a 1.5-second limit. A pattern that backtracks catastrophically, such as (a+)+b against a long run of a's, is stopped with an explanation instead of freezing the tab. Patterns written for PCRE, Python or .NET may need changes: possessive quantifiers, atomic groups, recursion, \A and \Z don't exist in JavaScript.

Privacy

Patterns and test strings stay in this browser tab: matching happens in a local Web Worker and nothing you type is uploaded, logged or stored, so it is safe to test against real log lines or customer data.

Features

The real JS engine

Matches exactly like RegExp in browsers and Node.js, including v-flag sets and named groups.

Token-by-token explanation

Every group, class, anchor and quantifier described in plain English.

Backtracking protection

Matching runs in a worker with a 1.5-second limit, so a bad pattern can’t freeze the page.

Regex tester: frequently asked questions

Which regex flavor does this tester use?
JavaScript's, as defined by the ECMAScript standard and implemented by the browser you're using. It supports lookbehind, named groups, Unicode property escapes and the v flag, but not PCRE features such as possessive quantifiers, atomic groups, recursion or conditionals. Python's (?P<name>…) syntax must be written (?<name>…) here. Results match Node.js and Deno on the same engine version.
Why does my pattern only find the first match?
Without the g flag, JavaScript stops after the first match: exec and match return one result and replace changes only the first occurrence. Switch on g to find and replace every match. The sticky y flag is different: it only matches at the exact position where the previous match ended, which is useful for tokenizers.
What is catastrophic backtracking?
When a pattern can match the same text in many different ways, as with nested quantifiers like (a+)+ or (.*)*, a failing match makes the engine try every combination, which grows exponentially with the input length. Here that stops after 1.5 seconds with a warning. Fix it by making alternatives mutually exclusive, for example [^,]* instead of .* before a comma.
How do I use capture groups in the replacement?
Write $1, $2 and so on for numbered groups, or $<name> for a named group such as (?<year>\d{4}). $& inserts the whole match, $` the text before it and $' the text after it, and $$ produces a literal dollar sign. Try an example loads a date pattern that reorders year, month and day this way.
When do I need the u or v flag?
Use u when your text contains emoji or other characters outside the Basic Multilingual Plane, so the dot and quantifiers treat them as one character, and to use \p{L}-style Unicode properties. The newer v flag includes everything u does and adds set operations inside brackets, such as [\p{L}--[a-z]] for non-ASCII letters. The two flags can't be combined.
All developer tools