Regex Tester
Test regular expressions with live highlighting and a capture group inspector.
Enter a pattern to begin.
Features
- Live match highlighting as you type
- Numbered and named capture group inspector
- All standard flags with one-click toggles
- Replacement preview with $1 backreferences
- Library of twelve common patterns
How to use it
- Type your pattern in the top field.
- Paste sample text into the box below.
- Matches highlight immediately; groups appear in the table.
- Add a replacement string to preview a substitution.
Flags, greediness and catastrophic backtracking
The flags change behaviour more than newcomers expect. Without g, only the first match is returned. The m flag makes ^ and $ match at line boundaries rather than only at the start and end of the whole string. The s flag lets . match newlines, which it otherwise never does, the single most common reason a pattern fails on multi-line input.
Quantifiers are greedy by default, meaning <.+> against <a><b> matches the entire string rather than just <a>. Adding ? makes them lazy, so <.+?> stops at the first closing bracket. Knowing which you want is usually the difference between a pattern that works and one that almost works.
The genuine hazard is catastrophic backtracking. Nested quantifiers such as (a+)+b can take exponential time on input that nearly matches, a few dozen characters can hang the engine for minutes. This has taken down production services; Cloudflare's 2019 global outage was caused by exactly this. If a pattern will ever see untrusted input, avoid nesting quantifiers, and prefer atomic constructs or a hard input length limit. This tool caps execution to keep the tab responsive if you hit one.
Frequently asked questions
Related tools
Further reading
Read the full guide on the 123MiniApps blog.