How to test a regular expression
- Type the expression in the first field, without the surrounding slashes.
- Check the options you need, such as ignoring case or finding all matches.
- Paste your test text: matches are highlighted and listed with their groups.
- If you like, type a replacement and copy the resulting text.
What a regex tester is for
A regular expression (regex) is a pattern for searching, validating or replacing text: emails, phone numbers, dates, codes. Testing it before using it in your code saves you errors and time.
This tool uses the JavaScript regular expression engine, the same one in your browser and in Node.js. It marks every match in the text and shows the value of each capture group, including named ones.
The replacement supports $1, $2 and the rest of the JavaScript syntax, so it is useful for preparing a bulk change before applying it.
Things to keep in mind
- It works with JavaScript syntax. Other languages (Python, PHP, Java) differ in some constructs.
- A badly written expression can take a very long time (excessive backtracking). If it goes over 2 seconds, it is stopped and you are notified.
- At most the first 1000 matches are shown.
Frequently asked questions
What do the g, i, m, s and u flags mean?
g finds all matches, not just the first. i ignores uppercase and lowercase. m makes ^ and $ apply on every line. s lets the dot match line breaks. u turns on Unicode mode.
Which language is it compatible with?
JavaScript. The basic constructs (classes, groups, quantifiers, anchors) are the same in almost every language.
How do I use groups in the replacement?
Use $1, $2, etc. for numbered groups, $& for the whole match and $<name> for named groups.
Is my text sent to any server?
No. Everything happens in your browser and your text never leaves your device.
Is it free?
Yes, it is free, requires no sign-up and works directly in your browser.