Regex Tester

Regex Tester (JavaScript Regular Expressions)

Enter a pattern and some text to see every match highlighted as you type. The match list shows positions and capture groups, and you can preview a replacement. Pick a common pattern to get started. Everything runs in your browser.

Flags

Matches

Match list

#PositionMatchGroups

Result

Result
Quick reference
.
Any character (except line breaks without the s flag)
\d \w \s
Digit / letter, digit or _ / whitespace (\D \W \S are the opposites)
^ $
Start / end of the text (of each line with the m flag)
* + ? {2,4}
0 or more / 1 or more / 0 or 1 / 2 to 4 times (add ? for the shortest match)
[abc] [^abc] [a-z]
One of / none of / range
(…) (?:…) (?<name>…)
Capture group / non-capturing group / named group
a|b
a or b
(?=…) (?!…) (?<=…) (?<!…)
Followed by / not followed by / preceded by / not preceded by
\b
Word boundary
\p{Script=Han}
Characters of a script (needs the u flag)
  • This tool uses the JavaScript (ECMAScript) regular expression engine of your browser. Results may differ slightly in PHP, Python, Ruby and other languages.
  • In the replacement, $1 to $99 insert groups, $<name> a named group, $& the whole match, and $$ a literal $.
  • To keep the page responsive, matching stops after about 2 seconds, the test string is limited to 200,000 characters, and up to 10,000 matches are counted.

About this tool

Test JavaScript regular expressions instantly. Matches in your test string are highlighted, with a list of positions, groups and named groups, and a live replacement preview. Start from common patterns such as email addresses, URLs, dates and Japanese postal codes, and use the quick reference while you work. Everything runs in your browser, and heavy patterns are stopped after about 2 seconds so the page does not freeze.

How to use

  1. Enter a regular expression in Pattern and choose the Flags (g, i, m, s, u, y), or pick one from Common patterns.
  2. Type or paste text into Test string. Matches are highlighted and counted.
  3. Check the positions and group values in the Match list.
  4. Enter a replacement using $1 or $<name> in Replace with to see the Result, then Copy it.

Useful for

  • Writing regular expressions for form validation
  • Checking a pattern before a bulk find-and-replace in your editor
  • Extracting specific parts from logs or data
  • Learning regex syntax by trying it out

FAQ

What is a regular expression?

A way to describe a pattern of characters, such as four digits or text containing @, using symbols. It is used for searching, replacing and validating input.

Can I test PHP or Python regex here?

The tool uses your browser's JavaScript regular expressions. The basics are the same, but some syntax and results differ between languages.

Why is only one match shown?

Without the g flag, only the first match is found. Tick g to find all matches.

Is my text sent anywhere?

No. Matching happens entirely in your browser.

Contact