All tools run in your browser — your files never leave your device.
All tools154

Developer & Security

Regex Tester

Test patterns live with match highlighting and a capture group table.

What it does. A regex tester lets you write a regular expression and see immediately what it matches in sample text. This tool highlights every match, breaks out numbered and named capture groups in a table, previews replacements, and includes a syntax reference. It uses your browser’s native JavaScript regex engine.
Runs in your browserNothing uploadsNo signupWorks offline

How to use Regex Tester

  1. Enter your pattern and set the flags — g for global, i for case-insensitive, m for multiline.
  2. Paste test text below. Matches highlight as you type in either field.
  3. Read the capture group table, or switch to replace mode to preview a substitution.

What do the regex flags do?

What do the regex flags do?
FlagNameEffect
gglobalFind every match, not just the first
iignore caseMatch regardless of capitalization
mmultiline^ and $ match at each line break, not just string start and end
sdotAll. also matches newline characters
uunicodeCorrect handling of astral characters and \p{...} property escapes
ystickyMatch only at the exact lastIndex position
dindicesReport start and end offsets for each capture group

The one that surprises people is m. Without it, ^ matches only the very start of the input, so a pattern intended to match the beginning of every line silently matches once. With m, it matches after every newline — which is what you almost always meant.

What is the difference between greedy and lazy quantifiers?

A greedy quantifier — *, +, {2,} — consumes as much as possible, then backtracks until the rest of the pattern can match. A lazy one — *?, +? — consumes as little as possible and expands only as needed.

The classic demonstration is HTML tags. Against <b>bold</b>, the pattern <.*> matches the entire string, because .* grabs everything and then backtracks to the last >. The pattern <.*?> matches just <b>.

Most extraction bugs come from a greedy quantifier swallowing past the intended boundary. When a match is longer than expected, adding ? after the quantifier is the first thing to try.

What are named capture groups?

A capture group with a label instead of just a number. Write (?<year>\d{4}) and the match exposes groups.year rather than [1].

The benefit is maintainability. A pattern with six numbered groups becomes unreadable, and inserting a group at the front renumbers everything after it — silently breaking whatever consumed the old indices.

They also work in replacements: $<year>-$<month> is far clearer than $1-$2. Named groups are supported in every current browser, in Python, in .NET, in PCRE and in Java. This tool shows both the number and the name for every group.

What is catastrophic backtracking?

A pattern that takes exponential time on certain inputs, hanging the thread it runs on. It is a real denial-of-service vector — ReDoS — and it has taken down production systems including a well-publicized Cloudflare outage in 2019.

It happens when nested quantifiers create multiple ways to match the same text. The pattern (a+)+$ against a long string of "a" characters followed by a "b" forces the engine to try every possible partition before concluding there is no match. Thirty characters can mean over a billion attempts.

The signs to look for are a quantifier applied to a group that itself contains a quantifier, and alternations where the branches can match the same input. Rewriting (a+)+ as a+ fixes the example without changing what it matches. This tool runs matching with a timeout so a pathological pattern reports a warning rather than freezing the page.

Frequently asked questions

Which regex flavor does this use?

JavaScript, specifically the ECMAScript 2018+ engine built into your browser. It differs from PCRE, Python re and .NET in a few areas — lookbehind support, some property escapes, and possessive quantifiers, which JavaScript lacks.

How do I match a literal dot?

Escape it as \. — an unescaped dot matches any character except a newline.

Why does my pattern only find the first match?

The g flag is missing. Without it the engine stops at the first match.

How do I match across multiple lines?

Use the s flag so . also matches newlines, and the m flag if you need ^ and $ to anchor to line boundaries.

Can I use regex to parse HTML?

For a narrow, known-shape extraction, sometimes. For general parsing, no — HTML is not a regular language, and nesting cannot be expressed in a regular expression. Use DOMParser.

What is a lookahead?

A zero-width assertion that checks what follows without consuming it. (?=...) requires a match ahead; (?!...) requires no match. Useful for password rules and for matching a position rather than text.

Is my test data uploaded?

No. Matching uses the browser native RegExp engine on this page.

Guides for Regex Tester