🔍 Regex Pattern Tester
Test regular expressions in real-time. See matches highlighted instantly as you type.
Regular expressions are write-only unless you can see them run. This tester evaluates your pattern against sample text in real time, highlights every match, and shows capture groups individually. It is the fastest way to answer the question every regex eventually raises: is this matching what I think it is matching, or is it matching something adjacent that happens to look similar.
Greedy versus lazy, in practice
The difference between `.*` and `.*?` decides whether your pattern stops at the first closing tag or the last one in the document. Greedy quantifiers take as much as possible and then backtrack; lazy ones take as little as possible. Most accidental over-matching comes from a greedy quantifier that was never examined. When a pattern works on one sample and fails on a longer one, this is the first thing to check.
Why catastrophic backtracking happens
Nested quantifiers such as `(a+)+` can make a regex engine explore an exponential number of paths on input that almost matches but does not quite. A 30-character string can hang the browser. The fix is to make the pattern more specific — anchor it, narrow the character classes, or replace nested quantifiers with a single bounded one. If a pattern gets slow as input grows, it is not a performance problem, it is a structural one.
Anchors and the multiline trap
By default `^` and `$` match the start and end of the whole string. With the multiline flag they match line boundaries instead, which is usually what people want when testing against a block of text and rarely what they get by default. The same applies to `.`, which does not match newlines unless the dotall flag is set. Two flags explain most of the cases where a pattern works in one tool and fails in another.
Frequently asked questions
Which regex flavor does this use?
It uses the JavaScript engine built into your browser, which follows the ECMAScript specification. Python, PHP and Java differ in details such as lookbehind support and named group syntax.
What do the flags mean?
g finds all matches rather than the first, i makes matching case-insensitive, m makes anchors match line boundaries, s lets dot match newlines, and u enables Unicode-aware matching.
Why does my pattern work elsewhere but not here?
Most often because of a flavor difference — a feature your other tool supports may not exist in JavaScript — or because a flag that was set elsewhere is off here.