Regex tester
Highlighted matches and groups
No database: AIMRAN doesn't store your files, text or results
What is Regex tester?
Regular expressions are patterns for finding text: emails, phone numbers, dates or any format. This tester lets you write a pattern and instantly see which parts of the text match, highlighted in color.
It also shows the capture groups for each match and lets you test replacements. A cheat sheet with the most common syntax is included so you don't have to look it up.
How to use it
- Type the pattern into “Regular expression” or paste a /pattern/flags literal.
- Turn on the flags you need: g, i, m, s, u or y.
- Paste the text into “Test text” and review the highlighted matches.
- Check each match's groups in the list.
- Turn on “Replace” and use $1, $<name> or $& to see the replaced text.
Advantages
- Highlighted matches and named groups in real time.
- Replacement testing with group references.
- Protection against catastrophic backtracking: the page never freezes.
- Free, with no sign-up.
Use cases
- Test the pattern that validates an email, phone number or ZIP code in a form before putting it in your code.
- Extract dates, amounts or IP addresses from a pasted log and check the capture groups of each match.
- Build a find-and-replace with groups, for example to turn MM/DD/YYYY dates into YYYY-MM-DD.
- Detect whether a pattern with nested quantifiers causes catastrophic backtracking before using it in production.
Technical details
It uses JavaScript's regular expression engine (ECMAScript), with support for named groups (?<name>…), lookbehind, Unicode classes with the u flag, and the g, i, m, s (dotAll), u and y (sticky) flags. Execution runs in a Web Worker with a 1.5-second limit: if a pattern with nested quantifiers such as (a+)+ causes catastrophic backtracking, the worker is stopped and a warning is shown. Up to 300 matches are listed with their position and their numbered and named groups. Replacement uses String.prototype.replace with $1, $<name> and $& syntax. Syntax error messages are explained in plain English.
Frequently asked questions
What is a regular expression?
A pattern that describes a set of text strings. For example, \d{5} finds any group of five digits, such as a ZIP code.
What is the g flag for?
It finds all matches in the text, not just the first one. Without it, the tester shows only the first.
How do I use a capture group in the replacement?
With $1, $2… for numbered groups, $<name> for named groups and $& for the whole match.
Does this regex work the same in Python or PHP?
The basic syntax is very similar, but the tester uses the JavaScript engine. Some features, such as possessive groups, differ between languages.
Why does my regular expression hang?
Probably because of catastrophic backtracking, caused by nested quantifiers such as (a+)+. The tester stops it after 1.5 seconds and warns you.
Related tools
- Find and replace · Several rules at once, with or without regular expressions
- Cron expressions · Explanation and next runs
- SQL formatter · Format or minify queries
- Clean text · Spaces, line breaks, emojis and HTML
- URL parser · Parts, parameters and rebuilding
- Base64, URL and HTML · Encode and decode in all three formats