Regular Expression Tester
Test JavaScript regular expressions live, with highlighted matches and capture groups.
Why use this tool?
Test JavaScript regular expressions against sample text, with every match highlighted and capture groups listed.
How to use it
- Enter your pattern and flags (g, i, m, s, u, y).
- Paste the test text.
- Review matches and groups as you edit.
Testing a pattern
Type a regular expression and some sample text, and every match is highlighted as you edit, with capture groups listed for each match. The tester uses your browser's JavaScript regex engine, so results match what the same pattern does in JavaScript and Node.js. Other languages (Python, PHP, Java, .NET) are similar but differ in details, especially around lookbehind, named groups and Unicode classes.
Flags change how the pattern runs: g finds all matches instead of just the first, i ignores case, m makes ^ and $ match at each line, s lets . match line breaks, u enables full Unicode handling and y (sticky) matches only at the current position.
Building blocks worth knowing
\d matches a digit, \w a letter, digit or underscore, \s whitespace, and . any character except a line break. Quantifiers repeat the previous item: * (zero or more), + (one or more), ? (optional) and {2,4} (two to four times). Square brackets define a set, so [aeiou] matches any vowel and [^0-9] anything that isn't a digit.
Parentheses create capture groups that extract parts of a match: (\d{4})-(\d{2})-(\d{2}) on 2026-10-12 captures 2026, 10 and 12. Use (?:...) for grouping without capturing, and (?<year>...) to name a group.
Common pitfalls
Quantifiers are greedy by default: <.+> on <b>bold</b> matches the whole string, not just <b>. Add ? to make them lazy (<.+?>). Special characters like . * + ? ( ) [ ] { } | \ ^ $ must be escaped with a backslash to match them literally, so matching a full stop is \.
Validate input with anchors: without ^ and $, a pattern for five digits also matches inside 1234567. And beware nested quantifiers like (a+)+ on long input; they can take exponentially long (catastrophic backtracking) and freeze a page or server.
Frequently asked questions
Which regex flavour does this use?
JavaScript's, as built into your browser. Most syntax carries over to other languages, but check advanced features in your target language.
Why does my pattern match too much?
Quantifiers are greedy. Add ? after them (.*? instead of .*) to match as little as possible.
How do I match a literal dot or bracket?
Escape it with a backslash: \. matches a dot, \[ a bracket.