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

  1. Type the pattern into “Regular expression” or paste a /pattern/flags literal.
  2. Turn on the flags you need: g, i, m, s, u or y.
  3. Paste the text into “Test text” and review the highlighted matches.
  4. Check each match's groups in the list.
  5. Turn on “Replace” and use $1,
    lt;name> or
    amp; to see the replaced text.

Advantages

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,

lt;name> and
amp; 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,

lt;name> for named groups and
amp; 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.

More Developers tools