Tools › Learn › Regex Tester & Explainer
🔍

Regex Tester & Explainer

Test regular expressions with live highlighting, capture groups and a plain-English explanation of your pattern.

🎯 Live highlighting
📖 Explains your pattern
🔁 Replace preview
🔒 Private
1️⃣

Write a pattern

Type a regular expression or pick an example.

//
g all matches · i ignore case · m ^ $ per line · s dot matches line breaks · u Unicode
Examples
2️⃣

Add text to test

Matches are highlighted as you type.

0 characters
🔁

Replace (optional)

Preview a find-and-replace. Use $1, $2 or $<name> for groups.

3️⃣

Matches

Highlighted in your text, with positions and groups.

0 matches
📚

Regex cheat sheet

Click a snippet to insert it into your pattern.

Advertisement

How to use

  1. Type a regular expression in the pattern box, or click one of the examples (phone number, email, PAN, PIN code and more).
  2. Paste or type the text to test. Matches are highlighted instantly, and listed with their position and capture groups.
  3. Switch flags on or off — for example i to ignore case — and read the plain-English explanation of your pattern.
  4. Optionally preview a replacement, then copy the matches, the JSON or the replaced text.

What is a regular expression?

A regular expression (regex) is a pattern that describes text. It can find every phone number in a document, check that an input looks like an email, or replace dates from one format to another. \d{10}, for example, means “ten digits in a row”.

This tester uses JavaScript regular expressions, the flavour used in browsers and Node.js. Most basics are the same in other languages, but some features (such as lookbehind, named groups or flags) differ, so check your language’s documentation before copying a pattern.

How to read the results

Every match is highlighted in your text, with alternating colours so neighbouring matches are easy to tell apart. The table lists each match with its position (index, counting from 0) and the text captured by each group: $1, $2 and so on, or the group’s name. The explanation panel breaks your pattern into parts in the order they appear.

Slow patterns are stopped safely

Some patterns, such as (a+)+$ on a long string of a’s, can take a very long time because the engine tries a huge number of combinations (“catastrophic backtracking”). The tester runs your pattern in the background and stops it after a short time, so your browser never freezes.

Frequently asked questions

How do I test a regular expression online?

Enter your pattern in the pattern box and some sample text below it. Matches are highlighted immediately, and you can adjust the pattern or flags until it matches what you expect.

What do the regex flags g, i, m, s and u mean?

g finds all matches instead of just the first. i ignores upper/lower case. m makes ^ and $ match at the start and end of each line. s lets the dot match line breaks. u turns on full Unicode support.

How do I match a phone number, email or PAN?

Use the examples above the pattern box: they include a 10-digit number, Indian mobile numbers, email addresses, PAN, PIN codes and IFSC codes. Click one, then adjust it for your data. Remember that format checks only confirm the shape, not that a number or address really exists.

What is a capture group?

Brackets around part of a pattern, such as (\d{2})/(\d{2}), capture the text they match so you can reuse it. They appear as $1, $2 in the results table and can be used in the replacement, e.g. $2/$1 swaps the two parts.

What is the difference between greedy and lazy matching?

Quantifiers like .* are greedy and match as much as they can. Adding a question mark (.*?) makes them lazy so they match as little as possible, which is handy for text between tags or quotes.

Why does my pattern show an error?

The message comes straight from your browser’s regex engine. Common causes are an unclosed bracket or parenthesis, a quantifier with nothing before it, or a feature your browser doesn’t support, such as lookbehind in older Safari.

Is my text sent anywhere?

No. Everything runs in your browser, so the patterns and text you test stay on your device.

Is this regex tester free?

Yes, it is free and has no sign-up or usage limits.