Regex Tester
Test and debug regular expressions with real-time match highlighting.
Write and test regular expressions against your own text. Matches are highlighted as you type, with the number of matches and capture groups, and a table of each match's position, groups and named groups. Turn flags on and off (global, ignore case, multiline, dot matches newline and Unicode), and try a replacement with $1, $2 or $<name> to see the result before you use it in code. The tester uses your browser's JavaScript regex engine, which handles most patterns the same way as Python, Java and PCRE; lookbehind and named groups work in all current browsers.
Use $1, $2 or $<name> to insert captured groups, $& for the whole match.
Uses your browser's JavaScript regex engine (the same syntax as Node.js and TypeScript).
Common use cases
- Build a pattern to validate input such as postcodes or IDs
- Debug a regex that matches too much or too little
- Test a find-and-replace before running it on a file
- Learn regular expressions by experimenting
How to use
- Type your pattern without the surrounding slashes.
- Paste test text and tick the flags you need.
- Check the highlighted matches and the groups table.
- Optionally enter a replacement to preview the result.
FAQ
Why does my pattern only match once?
Without the g (global) flag, JavaScript stops at the first match. Tick Global to find them all.
Why don't ^ and $ match each line?
By default they match the start and end of the whole text. Turn on the m (multiline) flag to match at each line break.
Will my pattern work in Python or PHP?
Most patterns will. Differences show up in less common features, such as possessive quantifiers and inline flags. The regex cheat sheet lists the common syntax.
Related tools
- Regex EscapeEscape special regex characters for literal string matching.
- Wildcard to RegexConvert wildcard patterns with * and ? to regular expressions.
- Text Diff CheckerCompare two texts and highlight differences between them.
- Regex to WildcardConvert simple regular expressions back to wildcard patterns.
- CRC32 Hash GeneratorGenerate CRC32 checksums for quick data integrity checks.
- SHA-512 Hash GeneratorGenerate SHA-512 hash values for maximum security hashing.