Developer tool

Regex Tester

Enter a pattern, choose flags and test it against your text instantly.

Runs in your browser. No upload.

Regular expressions run locally in your browser.

Matches0
No matches yet.

About this tool

Regex Tester made simple.

Use it to debug patterns before putting them in JavaScript, a form validation rule or a search workflow. Everything runs locally.

Guide

Using Regex Tester

Type a pattern, add flags and paste some text, and this page lists every piece of the text that matches. It uses the regular expression engine that is built into your browser, which is the JavaScript one, so a pattern that works here behaves the same in JavaScript code. Other languages such as Python, PHP or Java have their own differences. The page lists matches as text; it does not highlight them or explain the pattern.

How to use it

  1. Type your pattern in the Pattern box, without the slashes. For example, \b\w+@\w+\.com\b looks for simple email addresses.
  2. Check the Flags box. It starts with gi, which means all matches and ignore case. Delete or change letters to suit your test.
  3. Paste the text you want to search into the large Text to test box.
  4. Press Test expression. The Matches number shows how many were found, and each match is listed below.
  5. If you see an error, fix the pattern or flags. Press Clear to empty the boxes and set the flags back to gi.

Worked examples

Find every simple email address

You enter
Pattern
\b\w+@\w+\.com\b
Flags
g
Text
Mail [email protected] or [email protected] today

The g flag keeps looking after the first hit, so both addresses are found. This pattern is deliberately simple and will miss many valid addresses.

Run through the tool’s own code.

Groups with and without the g flag

You enter
Pattern
(\d{4})-(\d{2})-(\d{2})
Flags
Text
Due 2026-03-14 and 2026-04-01
You get
Matches
1
First
2026-03-14
Details
Index: 4; Groups: 2026; 03; 14

With no g flag, only the first match is returned. The page adds the start position and the three captured groups under it. Add g to the flags and the count becomes 2.

Run through the tool’s own code.

Greedy against lazy

You enter
Patterns
<.+>; <.+?>
Flags
g
Text
<b>x</b>
You get
Greedy
<b>x</b>
Lazy
<b>; </b>

A plain + grabs as much as it can, so one match covers the whole string. Adding ? after it makes it stop at the first possible end, which gives the two tags.

Run through the tool’s own code.

A pattern that can match nothing

You enter
Pattern
a*
Flags
g
Text
baab
You get
Matches
4
List
(empty); aa; (empty); (empty)

The star allows zero letters. So an empty match is found before the b, then aa, then empty matches before the last b and at the very end. Empty matches show as blank lines.

Run through the tool’s own code.

When it helps

  • Try a pattern before pasting it into JavaScript code, a form check or a search-and-replace.
  • Pull dates, numbers or codes out of a pasted log, list or document and count them.
  • Learn what a flag such as i, m, s or u changes by switching it on and off on the same text.
  • Check why a pattern matches too much, such as the greedy tag example, by comparing small variations.
  • Test a pattern on a few lines of sample text without writing a script.

Limits to keep in mind

  • It uses your browser's JavaScript engine only. Syntax from other languages, such as (?i) at the start or (?P<name>...), is rejected as an invalid group.
  • A test that runs for more than 1 second is stopped, and the page asks you to simplify the expression. Patterns with heavy backtracking can trigger this.
  • The page lists the matched text, and the start position is shown only for matches that have capture groups. It does not highlight matches inside your text.
  • There is no replace mode and no step-by-step explanation of what each part of the pattern does.
  • Error messages for a bad pattern or flag come from the browser itself, so the wording differs between browsers.

Tips

  • Build the pattern in small pieces. Add one part, test it, then add the next, so you know which part broke it.
  • Write a few lines that should match and a few that should not, and test them together.
  • Remember that the dot does not match a line break unless you turn on the s flag.
  • Use ^ and $ with the m flag when you want to match at the start and end of each line, not of the whole text.

Sources

Common questions

About Regex Tester.

Which regular expression engine does this use?

The one built into your browser, which is the JavaScript engine that follows the ECMAScript specification. The pattern is run with the standard RegExp object, so results match what the same pattern does in JavaScript code in that browser.

Do I type the slashes around the pattern?

No. Type only the pattern in the Pattern box and the flags in the Flags box. In JavaScript code you would write /pattern/flags, but here the two parts are kept apart, so slashes in the box are treated as characters to match.

Which flags can I use?

Any flags your browser's JavaScript supports, such as g, i, m, s, u and y. An unknown letter gives an error. The default is gi, and the Clear button restores it. MDN lists every flag and what it does.

Why do I get only one match?

You probably left out the g flag. Without it the search stops at the first match. Add g to the flags box and press Test expression again to list them all.

Will my pattern work in Python, PHP or Java?

Often, but not always. Basic parts such as classes, groups and quantifiers are shared, yet details differ. Python writes named groups as (?P<name>...), which JavaScript rejects, and inline flags like (?i) do not work here. Test in the language you will use.

Why did I see a message about taking too long?

The test runs in a background worker with a 1 second limit. Some patterns try an enormous number of paths on certain text, known as catastrophic backtracking. The page stops the test and asks you to simplify it.

How do I see my capture groups?

When a match contains capture groups, the page prints a line below it with the start index and the list of groups. Named groups, such as (?<year>\d{4}), are shown by name as well.

Why are there blank lines in my results?

A pattern like a* can match zero characters, and each empty match is counted and listed as a blank line. The count at the top includes them. Use a+ if you want at least one character.

Is my text sent to a server?

No. The pattern and text are tested in your browser, in a worker on your own device. Nothing is uploaded. Still, avoid pasting real passwords or private data into any test box on a shared computer.

How do I test a regular expression?

Enter a JavaScript regular expression, add any flags you need, paste sample text and select Test expression.

Which regex flags can I use?

Use flags supported by JavaScript regular expressions, such as g for all matches, i for case-insensitive matching and m for multiline matching.