How do I test a regular expression?

Enter a pattern and some sample text and the tool highlights every match, lists the capture groups and lets you turn flags such as global, multiline and case-insensitive on and off. Matching runs in your browser using JavaScript’s own regular-expression engine, so the results are exactly what your code will see.

Runs entirely in your browser · no upload · no account · no watermark

  1. Type a pattern and tick the flags you want.
  2. Paste some sample text to match against.
  3. Read the highlights, then the match list below.
Flags

Highlights

Matches

    What this page can do

    When to use this page

    • Trying a JavaScript regular expression against a sample string.
    • Seeing which capture groups and flags produce which matches.
    • Sanity-checking a pattern before putting it into front-end code.

    When to use something else

    • The pattern targets Python, PCRE, .NET or Java — syntax and backtracking behaviour differ from JavaScript’s RegExp.
    • The input is untrusted and the pattern could backtrack catastrophically; the test runs on the main thread and can freeze the tab.
    • You need step-by-step explanation, benchmarking or a timeout.

    How it compares with other options

    regex101 and similar tools let you switch engines, explain each token and impose a timeout. This page runs the browser’s own RegExp with none of those protections, so it is faithful to JavaScript but shares its limitations: no atomic groups, no possessive quantifiers, and no guard against a pathological pattern. A deliberately bad expression can hang the tab until you close it.

    Where your files go

    Nowhere. This page loads the code that does the work, and from then on the file you open is read by your own browser. There is no upload step, no temporary server copy and no cleanup to trust — the data never crosses the network, so there is nothing to delete afterwards. You can confirm it yourself: open your browser’s network panel while the tool runs and watch it stay quiet.

    Questions about this tool

    The page stopped responding when I used my pattern. Why?
    That is catastrophic backtracking: a pattern such as (a+)+b against a long run of “a” makes the engine try an exponential number of ways to fail. This page caps the number of matches so it cannot spiral forever, but a single stubborn match can still take a moment. Rewrite nested quantifiers so the engine has only one path — for example a+b — or anchor the pattern with ^ or $.
    Which flags can I turn on?
    g finds every match instead of the first, i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines too, and u switches on full Unicode mode, which is needed for \p{...} property escapes and correct handling of characters outside the basic plane. The results are exactly what JavaScript’s own engine gives you, so they match your code.
    Why are there only a few thousand matches listed?
    The list is capped so a pattern that matches on every character — for example . with the global flag on a long document — cannot lock up the tab while it builds thousands of rows. The cap is high enough for realistic test strings; if you hit it, narrow the pattern or shorten the sample.

    Other tools in the same group