Live highlighting of matches, capture groups and positions, plus a replace preview and built-in patterns for phone / email / URL / IP and more. Runs fully in your browser; nothing is uploaded.
| Token | Matches |
|---|---|
. | Any single character except a newline (unless dot-all is on) |
* | Zero or more of the preceding token |
+ | One or more |
? | Zero or one, or makes the preceding quantifier lazy |
[abc] | Any one character in the set; [^abc] negates it |
^ $ | Start and end of the string (or line, in multiline mode) |
\d \w \s | Digit, word character, whitespace |
( ) | Groups, and captures what it matched |
| | Alternation — this or that |
Quantifiers match as much as possible, then give back only when the rest of the pattern fails. Applied to <b>one</b><b>two</b> with the pattern <b>.*</b>, the greedy match swallows both tags as a single result. Adding ? — <b>.*?</b> — makes it lazy and returns each pair separately. This one character is behind a large share of regular-expression surprises.
Patterns with nested quantifiers, such as (a+)+, can take exponential time on input that almost matches but fails. A short string can freeze a process for minutes — a denial-of-service vector known as ReDoS. The defences are to avoid nesting quantifiers, prefer possessive or atomic groups where supported, and anchor patterns to the start of the input.
(?P<name>...) in Python, (?<name>...) in JavaScript and .NET.Always test a pattern in the same engine that will run it. A pattern that works perfectly on one site can fail silently in another.
HTML is not a regular language, and nested structures defeat pattern matching. A regex may work on today's markup and break on the next page. Use a real parser for HTML, XML and JSON, and reserve regular expressions for genuinely flat, regular text.