Flags
Test text
Result
The result will appear here
Results appear as you typeShortcut: Ctrl + Enter to run

How to use the Regex Tester

  1. Type the pattern in "Regular expression" — no surrounding slashes needed.
  2. Enter the text to test below, or press "Sample" to load an email example.
  3. Toggle flags such as global (g), case-insensitive (i) and multiline (m).
  4. 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

Input
Pattern: \(?\d{3}\)?[ -]?\d{3}-\d{4}
Text: Call (555) 123-4567 or 555-987-6543
Output
#1 (555) 123-4567
#2 555-987-6543

Reorder a date with groups

Input
Pattern: (\d{4})-(\d{2})-(\d{2})
Replace with: $2/$3/$1
Text: 2026-10-03
Output
10/03/2026

Regex cheat sheet

\d \w \sDigit, 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
\bWord boundary

Specs & key facts

EngineJavaScript (ECMAScript) RegExp
Flagsg global, i ignore case, m multiline, s dotAll, u Unicode
ShowsHighlighted matches, groups, named groups, replace preview
LimitsCounts up to 1,000 matches, lists the first 200
ProcessingIn your browser (nothing is uploaded)
PriceFree, 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.