🧰 Developer tools

Regex tester

Type a pattern and your text and see every match and group highlighted. Flags and a replacement preview are included. Nothing is uploaded.

Free · no signup Runs in your browser

MatchesType a pattern

    How do I test a regular expression?

    Type your pattern in the Pattern box, choose the flags and paste the text to test. Every match is highlighted, and the list shows where each one starts and what its groups captured. Tick Replace to preview a replacement, where $1 stands for the first group. The pattern runs in a separate worker that is stopped after 1.5 seconds, so a badly written pattern cannot freeze the page.

    A safe place to try patterns

    A regular expression is a compact way of describing text: three digits followed by a dash, a word at the start of a line, an email-like shape. They are powerful and easy to get slightly wrong, so seeing the matches highlighted as you type is the quickest way to learn and to debug them.

    This tester uses your browser's own JavaScript regular expression engine, so the result is exactly what your JavaScript code will do (other languages differ in small ways, especially around lookbehinds and named groups). The flags change the behaviour: 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, and u turns on full Unicode handling.

    Some patterns, such as (a+)+ applied to a long string of a's followed by a b, take exponentially longer as the text grows. This is called catastrophic backtracking, and on a normal page it would freeze the tab. Here the test runs in a worker that is terminated if it takes more than 1.5 seconds, and you are told why.

    It runs in your browser. What you type is never sent anywhere, and there is no sign-up.

    When to use it

    • Building a pattern for a form, a search or a script
    • Debugging a pattern that matches too much or too little
    • Previewing a replacement with groups before you run it
    • Learning how regular expressions work

    Mistakes it helps you avoid

    • Forgetting the g flag and wondering why only one match shows.
    • Using . when the text has line breaks: add the s flag.
    • Greedy patterns such as .* that match far more than you meant.
    • Nested repeats like (a+)+ that can freeze a program.

    How it works

    Everything happens in your browser as you type.

    • pattern + flags = new RegExp(pattern, flags), run by your browser's JavaScript engine
    • matches = each match with its position, its groups ($1, $2...) and any named groups
    • replacement = text.replace(pattern, replacement); $1 is the first group and $& the whole match
    • safety = the test runs in a worker that is stopped after 1.5 seconds
    • limit = up to 1,000 matches are listed

    The engine is the one built into your browser, so it follows the ECMAScript regular expression rules, including lookbehind and named groups in current browsers. Patterns for PCRE, Python or .NET may need small changes. Matching an empty string advances by one character to avoid an endless loop.

    Example: pulling out phone numbers

    You test (\d{3})-(\d{4}) against 'Call 555-0199 or 555-0123'.

    1. Pattern(\d{3})-(\d{4})
    2. Flagsg
    3. Matches2: 555-0199 (groups 555, 0199) and 555-0123
    4. Replace with $2-$1Call 0199-555 or 0123-555

    Two matches highlighted with their groups

    Remove the g flag to find only the first.

    Terms on this page

    Regular expression
    A pattern that describes text to find.
    Catastrophic backtracking
    A pattern that takes exponentially longer on some text and can freeze a program.

    Common questions

    Which regex flavour is this?

    JavaScript (ECMAScript), the one in your browser. Most basics are shared with other languages, but some features differ.

    What does the g flag do?

    It finds every match in the text instead of stopping at the first.

    Why was my pattern stopped?

    It took over 1.5 seconds, which usually means catastrophic backtracking. Simplify nested repeats such as (a+)+.

    Is my data uploaded?

    No. Everything is processed in your browser and never sent anywhere.

    How do I use groups in a replacement?

    Use $1, $2 for the numbered groups and $& for the whole match.

    Where these numbers come from

    Last verified 2026-10-25 The method on this page is checked against the sources above at least once a year. Spotted something out of date? Tell us and we will fix it.

    🧰 Developer and web tools

    Small developer and web jobs done in your browser. What you paste or choose is never sent anywhere.

    See all 24 tools in this section