Test JavaScript regular expressions against sample text with live match highlighting, a table of matches and capture groups, and replace and split previews. A token-by-token explanation breaks the pattern down, and a built-in cheat sheet covers syntax. All flags are supported, including d, v and sticky, as well as named groups.
Common uses
- Building a validation pattern before putting it in code
- Writing a find-and-replace using capture groups
- Understanding a regular expression someone else wrote
Frequently asked questions
- Which regex flavor is used?
- JavaScript (ECMAScript), because the tester runs your pattern with the browser engine. Patterns for PCRE, Python or Java may differ in lookbehind, named group syntax and flags.
- Can a pattern freeze my browser?
- Patterns with nested quantifiers can backtrack catastrophically on some inputs. If a test hangs, simplify the pattern or anchor it more tightly.
- How do I reference a capture group when replacing?
- Use $1, $2 and so on, or $<name> for named groups. $& inserts the whole match.