How to use the Regex Tester
- Type the pattern in "Regular expression" — no surrounding slashes needed.
- Enter the text to test below, or press "Sample" to load an email example.
- Toggle flags such as global (g), case-insensitive (i) and multiline (m).
- The right side shows the match count, highlighted positions and each match's groups; add a replacement such as $1 to preview a replace.
Examples
Extract US-style phone numbers
Pattern: \(?\d{3}\)?[ -]?\d{3}-\d{4}
Text: Call (555) 123-4567 or 555-987-6543
#1 (555) 123-4567
#2 555-987-6543
Reorder a date with groups
Pattern: (\d{4})-(\d{2})-(\d{2})
Replace with: $2/$3/$1
Text: 2026-10-03
10/03/2026
Regex cheat sheet
\d \w \s | Digit, word character, whitespace |
|---|---|
. | Any character except newline (includes newline with the s flag) |
* + ? {n,m} | 0 or more, 1 or more, 0 or 1, n to m times |
^ $ | Start and end (of each line with the m flag) |
( ) (?<name> ) | Capture group, named group |
(?: ) | Non-capturing group |
\b | Word boundary |
Specs & key facts
| Engine | JavaScript (ECMAScript) RegExp |
|---|---|
| Flags | g global, i ignore case, m multiline, s dotAll, u Unicode |
| Shows | Highlighted matches, groups, named groups, replace preview |
| Limits | Counts up to 1,000 matches, lists the first 200 |
| Processing | In your browser (nothing is uploaded) |
| Price | Free, no sign-up |
FAQ
Will a regex tested here work in PHP or Python?
Most basic syntax is the same, but engines differ: PHP's PCRE supports recursion and possessive quantifiers, and Python writes named groups as (?P<name>...). This tool uses the JavaScript engine, so double-check before using it elsewhere.
Why is only one match found?
Make sure the g (global) flag is on. Without it, a regex returns only the first match.
Why don't ^ and $ match each line?
By default they match the start and end of the whole text. Turn on the m (multiline) flag to match each line.
What does $1 in the replacement mean?
$1 and $2 insert the first and second capture groups, $& inserts the whole match, and $<name> inserts a named group.