How to Test Regular Expressions
Regex Testing
Regex Modes
- Match — test whether the pattern matches and show all matches with positions
- Replace — substitute matches with a replacement string (supports $1, $2 groups)
- Extract — list every match value from the input
Common Flags
g— find all matches, not just the firsti— case-insensitive matchingm— ^ and $ match line boundariess— dot matches newlines
JavaScript Regex Syntax
This tool uses JavaScript regular expressions (ECMAScript). Lookahead, capture groups, and backreferences follow JS semantics — which may differ from PCRE or Python regex.
Frequently asked questions
Why does my regex work in Python but not here?
Different languages have different regex engines. JavaScript lacks some PCRE features (e.g. recursive patterns) and has different escaping rules.
How do capture groups work?
Parentheses create capture groups. In Replace mode, use $1, $2, etc. to reference captured text. Match mode shows group values for each match.