Matches
| # | Match | Groups |
|---|---|---|
| 1 | support@example.com | — |
| 2 | billing@example.org | — |
Match found. Matches: 2 First match: support@example.com Replacement: Contact [email-redacted] or [email-redacted] for assistance.
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.
Last reviewed
Your inputs are saved as a draft in this browser only. Nothing is uploaded.
| # | Match | Groups |
|---|---|---|
| 1 | support@example.com | — |
| 2 | billing@example.org | — |
Match found. Matches: 2 First match: support@example.com Replacement: Contact [email-redacted] or [email-redacted] for assistance.
Match found. Matches: 2 First match: support@example.com Replacement: Contact [email-redacted] or [email-redacted] for assistance.
Pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 turns "Due 2026-10-30" into "Due 30/10/2026".
Pattern (?<year>\d{4})-(?<month>\d{2}) with replacement $<month>/$<year> turns "2026-10" into "10/2026".
^[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.
Pattern invoice with flags gi matches "Invoice", "invoice" and "INVOICE" everywhere in the text.
^ERROR.*$ with flags gm matches every line that starts with ERROR. Without m, ^ and $ match only the start and end of the whole text.
On "<b>bold</b>", the greedy <.+> matches the whole string, while the lazy <.+?> matches "<b>" and "</b>" separately.
To match "1.5" exactly, escape the dot: 1\.5. An unescaped . matches any character, so 1.5 also matches "125".