What this regex tester does
Regular expressions fail silently: an almost-right pattern simply matches the wrong things. The fix is a tight feedback loop, and that is what this tester provides — as you edit the pattern, flags or test text, every match is re-highlighted instantly and listed with its position and capture groups. Invalid patterns show the parser’s error message instead of pretending nothing matched.
The tester runs your pattern with the browser’s own JavaScript regex engine, so what you see here is exactly what String.match, RegExp.exec and String.replace will do in your code.
How to test a regular expression
- Type your pattern (no surrounding slashes needed) and any flags.
- Paste representative test text — include cases that should not match.
- Check the highlights and the match list, including capture groups.
- Refine until the matches are exactly right, then copy the pattern into your code.
Building patterns that survive real data
The habit that separates working regex from fragile regex: test against hostile input, not just the happy path. Add lines that are close-but- wrong, empty lines, and punctuation-heavy text. Prefer explicit character classes over the dot, anchor with \b or ^…$ where possible, and keep capture groups minimal. If you are extracting from JSON, validate the document first with the JSON Validator — a real parser beats regex for structured data.