Free Regular Expression Tester

Type a pattern and test text — matches highlight live, with capture groups listed below. JavaScript regex syntax.

/ /

Matches highlighted

      
Match details

    Two gotchas that trip up most regex beginners

    By default, quantifiers like *, +, and {n,m} are "greedy" — they grab as much text as possible before backing off if the rest of the pattern fails to match. Against <b>bold</b> and <i>italic</i>, the pattern <.*> greedily matches all the way from the first < to the very last > — swallowing both tags and everything between them — rather than stopping at the first > as many people expect. Adding a ? after the quantifier (<.*?>) makes it "lazy" instead, matching as little as possible, which correctly isolates just <b>.

    The second gotcha is what actually causes the freeze covered in the FAQ below: a pattern like (a+)+ has a quantifier wrapping another quantifier, so against a long run of "a" characters followed by one non-matching character, the engine has an exponentially growing number of ways to split those repeated groups before it can conclude there's no match — this is called catastrophic backtracking, and it's a well-documented denial-of-service vector (ReDoS) in real applications that run untrusted regex against user input.

    Frequently Asked Questions

    Which regex flavor does this tester use?

    JavaScript (ECMAScript) regular expressions — the same engine your browser uses. Most patterns are portable, but some features differ from other flavors: JavaScript uses (?<name>...) for named groups and does not support possessive quantifiers or atomic groups found in PCRE.

    What do the g, i, m, and s flags mean?

    g finds all matches instead of stopping at the first. i ignores letter case. m makes ^ and $ match at the start and end of each line rather than the whole text. s lets the dot (.) match newline characters.

    Why does my pattern freeze the page on large text?

    Patterns with nested quantifiers like (a+)+ can trigger catastrophic backtracking, where the engine tries an exponential number of combinations. Rewrite the pattern to avoid overlapping quantifiers, or anchor it more precisely.

    What's the difference between greedy and lazy quantifiers?

    A greedy quantifier (like .*) matches as much text as it can before backtracking. A lazy quantifier (.*?, with a trailing ?) matches as little as possible. Against HTML tags, a greedy pattern often swallows far more than intended — lazy quantifiers are usually what you actually want for "stop at the first closing character."

    What's a non-capturing group, and when should I use one?

    Writing (?:...) instead of (...) groups a piece of the pattern (for applying a quantifier to it, for example) without adding it to the numbered capture-group results. It keeps your match-details list focused on the groups you actually care about extracting.

    Is my test data uploaded?

    No. Matching runs entirely in your browser using its native regex engine. Your patterns and text never leave your device.