Quick access

Add to my tools

Regex Tester & Tutorial

Test regular expressions live with highlighted matches, groups, replace and a plain-English explanation — or learn regex step by step in 14 hands-on lessons.

/ /
Common patterns:


                        
                    

matches

Showing the first 1,000 matches.

No matches. Check the explanation below to see what the pattern looks for.

What this pattern means

Type a pattern to see it explained, piece by piece.

Use it in code


                

This tester uses JavaScript's engine. PHP (PCRE) and Python accept almost the same syntax; Python spells named groups (?P<name>…), which the snippet does for you.

Regex cheat sheet

Characters

.
any character except newline
\d \w \s
digit, word char, whitespace
\D \W \S
not digit / word / whitespace
[abc]
a, b or c
[^abc]
not a, b or c
[a-z]
a range
\.
a literal dot

Anchors

^
start of text (line with m)
$
end of text (line with m)
\b
word boundary
\B
not a word boundary

Quantifiers

*
0 or more
+
1 or more
?
0 or 1 (optional)
{3}
exactly 3
{2,5}
2 to 5
{2,}
2 or more
*? +?
lazy: as few as possible

Groups

(abc)
capture group
(?<name>abc)
named group
(?:abc)
group without capturing
a|b
a or b
\1
same text as group 1
(?=abc) (?!abc)
followed / not followed by
(?<=abc) (?<!abc)
preceded / not preceded by

Your task:

/ /

✓ Correct! You've finished every lesson — try the Tester with your own text.

Hint:

About the Regex Tester

A regular expression (regex) is a pattern for finding text, such as \d{3}-\d{4} for a phone-number fragment. The tester highlights every match as you type and explains what each part of the pattern does. New to regex? The Learn tab teaches it in 14 short lessons, each with a task you solve right on the page.

How to use it

  1. 1 Type your pattern and switch on the flags you need, such as g for all matches.
  2. 2 Paste the text to test and check the highlighted matches and capture groups.
  3. 3 Read the plain-English explanation, or switch to Replace to preview a substitution.
  4. 4 Copy the ready-made JavaScript, PHP or Python code.

Frequently asked questions

Which regex flavour is used?

JavaScript regular expressions, as used in browsers and Node.js. Most syntax is the same in PHP (PCRE) and Python; the code panel converts named groups to Python's (?P<name>…) form for you.

What do the g, i, and m flags do?

g finds all matches instead of just the first, i ignores case, and m makes ^ and $ match at the start and end of each line. s lets the dot match line breaks, and u turns on full Unicode support.

How do I match a literal dot?

Escape it with a backslash: \. On its own, a dot matches any character. The same goes for other special characters such as $ ( ) [ ] { } * + ? | ^ and \.

How do I learn regex as a beginner?

Open the Learn tab. It starts with plain text and builds up through character sets, shorthands like \d, quantifiers, anchors, groups, back-references, lookahead and flags. Each lesson has a small task checked as you type, and your progress is saved in your browser.

What is the difference between greedy and lazy?

Quantifiers like + and * are greedy and match as much as they can. Adding ? makes them lazy, so <.+?> matches each HTML tag separately instead of everything from the first < to the last >.

How do I use a capture group in a replacement?

Switch to Replace and use $1, $2 for numbered groups, $<name> for named groups and $& for the whole match. For example (\w+) (\w+) with $2 $1 swaps two words.

Why did my pattern stop with "catastrophic backtracking"?

Patterns with nested quantifiers, such as (a+)+ or (.*)*, can take exponential time on text that almost matches. The tester runs each pattern in the background and stops it after 1.5 seconds so the page never freezes. Rewrite the pattern so the repeated parts cannot overlap.