Regex Tester

  • Free, no sign-up
  • Runs in your browser
  • Updated
Quick answer. The Regex Tester runs your JavaScript regular expression against sample text as you type, highlights every match, lists capture groups, supports all flags and a replace mode, and includes a cheat sheet and common patterns.

Regex Tester tool

//g
Flags

2 matches

Contact ali@example.com or sara@test.com for help.
#MatchIndexGroup 1Group 2
1ali@example.com8aliexample
2sara@test.com27saratest
Regex cheat sheet
.Any character except newline
\d \w \sDigit, word character, whitespace
\D \W \SNot digit, not word, not whitespace
[abc] [^abc]One of / none of a, b, c
* + ?0 or more, 1 or more, 0 or 1
{2,5}Between 2 and 5 times
^ $Start / end of string (or line with m)
\bWord boundary
(…) (?<name>…)Capture group / named group
(?:…)Non-capturing group
a|ba or b
(?=…) (?!…)Lookahead / negative lookahead
Runs in your browser. Your data never leaves your device.

How to use the Regex Tester

  1. 1Type a pattern and choose flags (g, i, m, s, u, y).
  2. 2Paste test text. Matches are highlighted instantly.
  3. 3Check the groups table for capture group values.
  4. 4Switch on replace mode to preview a replacement string with $1 and named groups.

What is a regex tester?

A regex tester lets you try a regular expression (regex) against sample text and see what it matches before you use it in code. This tester highlights every match as you type, lists capture groups in a table, supports all JavaScript flags, has a replace mode with $1 and named groups, and includes a cheat sheet and a library of common patterns.

A regular expression is a small pattern language for finding text. For example, \d{4}-\d{2}-\d{2} finds dates like 2026-12-01.

How does the regex tester work?

It uses your browser's own JavaScript regular expression engine, the same one that runs your code in Chrome, Firefox, Safari or Node.js. The syntax follows the ECMAScript standard, documented clearly on MDN's regular expressions guide.

When you type, the tool:

  1. Builds a RegExp from your pattern and flags. If that fails, it shows the browser's error message.
  2. Runs matchAll (or a single match without the g flag) on your text.
  3. Highlights each match and fills the groups table with each match's position and captured groups.

It shows up to 1,000 matches so a pattern that matches every character can't freeze the page.

What do the flags do?

FlagNameEffect
gglobalFind all matches, not just the first
iignore casea matches A
mmultiline^ and $ match at the start and end of each line
sdotAll. also matches newline characters
uunicodeTreats emoji and other astral characters as one character; enables \p{…} classes
ystickyMatches only at the current position

Use u whenever your text may contain Urdu, Arabic or emoji and you use classes like \p{L} (any letter in any language).

Worked example

Pattern: \b(\w+)@(\w+)\.com\b with flag g Text: Contact ali@example.com or sara@test.com for help.

Results: 2 matches.

#MatchIndexGroup 1Group 2
1ali@example.com8aliexample
2sara@test.com27saratest

Turn on replace mode with $1 at $2 and the result is Contact ali at example or sara at test for help. With named groups, (?<user>\w+)@(?<site>\w+)\.com, the replacement can be written $<user> at $<site>, which is easier to read later.

Tips

  1. Start simple and grow. Match a fixed word first, then add classes and quantifiers one at a time.
  2. Escape special characters like . ? + * ( ) [ ] { } | \ ^ $ with a backslash when you mean them literally. A plain . in example.com matches any character.
  3. Use anchors and boundaries. \b stops cat matching inside category.
  4. Avoid catastrophic backtracking. Nested quantifiers like (a+)+$ can take exponential time on text that almost matches. Make inner parts more specific.
  5. Don't parse HTML or JSON with regex. Use the JSON Formatter for JSON, and real parsers for HTML.
  6. Compare before and after a replace with the Text Diff Checker.
  7. Writing Apache redirect rules? Test the path pattern here, then generate the rule with the .htaccess Redirect Generator.

Limitations

  • This is the JavaScript flavour. Most syntax is shared with PCRE (PHP), Python and Java, but features like possessive quantifiers (a++), atomic groups and \A/\Z anchors don't exist in JavaScript, and lookbehind support varies in older browsers.
  • The common patterns are practical starting points, not perfect validators. The email pattern, for example, accepts most real addresses but not every address the email standard allows.
  • Very slow patterns can still pause the page briefly before results appear.

For scheduling patterns rather than text patterns, see the Cron Expression Builder.

Frequently asked questions

Which regex flavour does it use?

Your browser’s JavaScript (ECMAScript) engine. Most syntax matches PCRE and Python, but some features, such as possessive quantifiers, differ.

Why do I only get one match?

Add the g (global) flag to find all matches instead of the first one.

What do the m and s flags do?

m makes ^ and $ match at each line break. s lets the dot match newline characters too.

Can a regex freeze the page?

Patterns with nested quantifiers, such as (a+)+, can take exponential time on some inputs. The tester limits the number of matches it shows to stay responsive.

Last updated: . Written and tested by Abdul Moid Khan, ATechCraft. Read how we build and test tools.