Developer Tools
Regex tester features
Regex Tester — highlights every match in your test string as you type the pattern. Capture groups are listed in a table, and named groups ((?'<name>'...)) appear under their own names. Toggle the g, i, m, s and u flags, and enter a replacement string to preview the rewritten text — group references such as $1 work. Patterns run under JavaScript (ECMAScript) regex rules.
How to use
1. Enter the pattern itself — leave out the surrounding slashes. 2. Toggle the flags you need. 3. Type a test string and matches are highlighted immediately. 4. To test a substitution, enter a replacement in the bottom field.
When to use it
• Build validation patterns for emails, phone numbers or dates • Pull one kind of line out of a log • Check a find-and-replace pattern before running it in an editor • Write input validation rules • Parse strings with named capture groups
Frequently Asked Questions
- Q. Which regex flavour is this?
- A. JavaScript (ECMAScript), as implemented by your browser. Some syntax differs from Python, Java and PHP — lookbehind, for instance, works in current browsers but support varies — so confirm the pattern in the language you will actually use.
- Q. Should the pattern include slashes?
- A. No. The slashes are already drawn around the field, so enter just the pattern. Flags are set with the buttons below.
- Q. How do I reference groups in a replacement?
- A. Use $1, $2 and so on by number, or $'<name>' for named groups. $& stands for the whole match.
- Q. What happens with very many matches?
- A. To keep the page responsive, matching stops at 2,000 results and says so. The group table shows the first 200.
- Q. Is my text sent to a server?
- A. No. Matching and replacement both run in your browser. Note that a complex pattern over a long string can still make the browser pause briefly.