Regex Tester

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.

Regular expression
/ / g
Common patterns (click to fill)
Test text Live match preview
Match details (first 200 shown)
Enter a pattern to list every match with its position and groups.
Replace (use $1, $2 to reference groups in the replacement; $& = the whole match)

The building blocks

TokenMatches
.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 \sDigit, word character, whitespace
( )Groups, and captures what it matched
|Alternation — this or that

Greedy by default

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.

Catastrophic backtracking

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.

Dialects differ more than people expect

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.

Do not parse HTML with regex

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.

Related tools

Text diff Line tools URL encoder

FAQ

What do the g, i, m, s and u flags mean?
g means global matching (find every result); i ignores case; m is multiline mode, so ^ and $ match the start and end of each line; s makes the dot . match newlines as well; u switches to Unicode code-point handling for emoji and rare characters. When testing matches, this tool always counts every match globally.
Does testing regexes online leak my data?
No. Matching, highlighting and replacement all run locally in your browser, and the text you enter is never sent to any server.
Why are there empty highlights in the results?
They come from zero-width matches such as \b, ^, $ and lookaheads like (?=...). These match a position rather than characters, so their length is 0 and the highlight block is hollow — that is normal.
Are there ready-made regexes I can use?
Yes. The tool ships with common patterns for phone numbers, email addresses, URLs, IPv4, dates, times, hex colors, integers, decimals and more — click a preset chip to fill it in and test immediately.