toolfree

Regex tester

Test a regular expression against your text, see every match highlighted, and read a plain-English breakdown of what each part of the pattern does.

Runs in your browser

Flags

What this pattern does

    Reading a pattern you did not write

    Most regex problems are comprehension problems: someone pasted a pattern into a validator years ago and nobody since has been able to say what it accepts. The panel below the matches breaks the pattern into its constructs and names each one, in order and indented by group, so a pattern can be read rather than decoded.

    Matches are highlighted in the test string as you type, which makes the common failures obvious at a glance — a pattern matching more than you meant, or matching in the middle of a word when you expected the whole of it.

    Flags

    FlagEffect
    gFind every match, not just the first
    iIgnore case
    m^ and $ match at each line break, not only at the ends of the text
    s. also matches a line break
    uUnicode mode: \u{…} escapes and \p{…} properties become available

    The m flag is the one most often wanted and least often set. Without it, ^ anchors to the start of the whole subject, so a per-line pattern silently matches once and stops.

    Greedy by default

    .* and .+ take as much as they can and then give characters back until the rest of the pattern fits. Against <b>one</b> <b>two</b>, the pattern <b>.*</b> matches the entire string, not the first tag pair. Adding ? makes the quantifier lazy — <b>.*?</b> stops at the first closing tag.

    That single character is the difference between a scraper that extracts one field and one that extracts the whole document.

    Catastrophic backtracking

    Nested quantifiers over overlapping alternatives, such as (a+)+$, can take exponential time on an input that does not match. A few dozen characters is enough to hang the engine outright — and since this tester runs the pattern in your own tab, a pattern like that will freeze this page too. It is the same failure that has taken down production services; the usual fix is to make the inner alternatives mutually exclusive so the engine has nothing to backtrack into.

    Flavours differ

    This page runs the browser’s own JavaScript engine, so what you see here is exactly what RegExp will do. Other flavours are close but not identical:

    Test a pattern in the environment that will run it before trusting it in production.

    Your data stays here

    The pattern and the text are evaluated in your browser. Nothing is sent anywhere, which matters when the sample you are testing against is real log output or customer data.