Regex tester for JavaScript

A regular expression (regex) is a pattern that describes a set of strings, used to search, validate, extract, or replace text.

Test JavaScript regular expressions with flags, see every match and capture group, and preview replacements. Free, and your text stays in your browser.

Browser-sideNo accountCopy, download, or print

Last reviewed

Your inputs are saved as a draft in this browser only. Nothing is uploaded.

Jump to result
Interactive workspace

Inputs

Result

More export options

Matches2
Flagsgi
Pattern length50
Replacementapplied

Matches

#MatchGroups
1support@example.com—
2billing@example.org—
Match found.
Matches: 2
First match: support@example.com
Replacement: Contact [email-redacted] or [email-redacted] for assistance.

Examples

Reformat dates with capture groups

Pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 turns "Due 2026-10-30" into "Due 30/10/2026".

Named groups

Pattern (?<year>\d{4})-(?<month>\d{2}) with replacement $<month>/$<year> turns "2026-10" into "10/2026".

Validate an Indian PIN code

^[1-9]\d{5}$ matches 560001 but not 056001, because PIN codes do not start with 0. The ^ and $ anchors make the whole string match, not just part of it.

Case-insensitive search

Pattern invoice with flags gi matches "Invoice", "invoice" and "INVOICE" everywhere in the text.

Match whole lines

^ERROR.*$ with flags gm matches every line that starts with ERROR. Without m, ^ and $ match only the start and end of the whole text.

Lazy versus greedy

On "<b>bold</b>", the greedy <.+> matches the whole string, while the lazy <.+?> matches "<b>" and "</b>" separately.

Match a literal dot

To match "1.5" exactly, escape the dot: 1\.5. An unescaped . matches any character, so 1.5 also matches "125".

How to use it

  1. Enter your regular expression pattern without the surrounding slashes, and any flags such as g, i, or m.
  2. Paste the text to test against.
  3. Review the match count, each match, and its capture groups.
  4. Add a replacement such as $1 or $<name> to preview the substituted output.

Questions

Which regex engine is used?
Your browser's native JavaScript RegExp engine, so results match what the same pattern does in JavaScript and Node.js. Other languages differ in places, so test there too if the pattern will run elsewhere.
What do the flags g, i, m, s, u and y do?
g finds all matches instead of the first, i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines, u enables full Unicode handling and \u{...} escapes, and y (sticky) matches only at the current position.
Does it show capture groups?
Yes. Each match lists its numbered and named groups so you can confirm the pattern extracts the right parts.
How do replacements reference groups?
Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match, and $$ for a literal dollar sign.
Why does a pattern that works in PCRE or Python fail here?
JavaScript does not support some features found in other engines, such as possessive quantifiers, atomic groups, recursion, and the \A and \Z anchors. Rewrite those parts with JavaScript syntax, for example ^ and $ instead of \A and \Z.
Why is my regex slow or stuck?
Nested quantifiers such as (a+)+ or (.*)* can backtrack exponentially on text that almost matches. Make the inner part more specific or remove the nesting, for example a+ instead of (a+)+.
Is my test text uploaded?
No. Matching runs entirely in your browser and nothing is uploaded.