Try your regular expression on text: matches are highlighted, groups listed, and you can preview a replacement.
No sign-up, no fees.
Regex test: matches are highlighted in the text.
The position and groups of each match are listed.
g, i, m, s, u flags.
See the replacement result ($1, $) instantly.
What you type is processed, but never shared with anyone.
How to use the Regex Tester
Try your regular expression here before putting it in code. Five steps:
Type the pattern. Write your expression in the Pattern box. Don't put / at the start and end; they're already there.
Pick the flags. Tick the ones you need under Flags (explained below).
Paste the text. Paste the text into the Text to test box.
Look at the matches. What matches is highlighted in the text. Below it you get a summary like "5 matches" and a list of each match's position and groups.
Replace (optional). If you write something like $2 $1 in the Replacement box, the Replaced text shows below.
What is a regular expression (regex)?
A regular expression (regex for short) is a small search language written to find a certain pattern in text. Jobs like "find all email addresses", "put phone numbers in the same format" or "turn dates into day-month-year order" are done in one line with regex. It's used in programming languages, text editors, Excel and databases. Once written right it's wonderful; until it's written, it's a puzzle. That's why a regex tester exists.
Flags
g: finds all matches. If off, it finds only the first.
i: ignores case. Note: in some languages, such as Turkish, dotted and dotless i are separate letters, and this flag doesn't pair them the way a Turkish reader would expect.
m:^ and $ match the start and end of each line.
s: the dot (.) also catches line breaks.
u: Unicode mode. Needed for emoji and letter classes like \p{L}.
Which regex engine?
The regular expression engine of JavaScript runs here. If you put in an expression written for Python, PHP (PCRE), .NET or Java, small differences can come up; for example, the inline flag (?i) of some languages doesn't work here.
If an expression hangs
A badly written expression, especially nested repeats like (a+)+, gets very slow on some texts. To keep the page from freezing, we stop the run at 2 seconds and tell you why. The text to test also runs under a length limit.
Tips for writing regex
Pattern
Meaning
\d+
One or more digits
\w+
Letters, digits or underscore (basic Latin letters only)
\p{L}+
A word in any alphabet (with the u flag)
^...$
The whole line (with the m flag)
(\d{2})\.(\d{2})
Two groups: like 12.05
Common mistakes
Not escaping the dot:. matches any character; for a literal dot write \..
Searching accented words with \w:\w doesn't cover letters like é, ñ or ü; write your own letter list in square brackets or use \p{L} with the u flag.
The expression runs in your browser. What you type is processed, but never shared with anyone.
Why are there no matches at all?
First make sure the g flag is on. Then check whether you need to escape special characters (., ?, ().
How are groups numbered?
Parentheses are numbered from left to right starting at 1. If you write (?<name>...), you name the group; it's used in replacement as $<name>.
What does $& mean?
In replacement it stands for the whole match. For example, [$&] wraps each match in square brackets.
Which regex for an email address?
For a simple check, [^\s@]+@[^\s@]+\.[^\s@]+ does the job. Full validation is complicated; the most reliable real check is sending a confirmation email.
Can I try my Python regex here?
Most expressions work the same but small differences are possible; the JavaScript engine is used here.
Can I use it on my phone?
Yes. Type the pattern and the text; matches are highlighted right away.
Where should I start when testing regex?
In small steps. First write a fixed part of what you're looking for and see it match; then generalize bit by bit. Looking at the highlights in the text at each step shows the mistake immediately.
How do I match line by line?
Turn on the m flag and start the pattern with ^ and end it with $. Each line is evaluated separately.
How does $1 work in the replacement box?
It stands for the text caught by the first parenthesis group in the pattern. The pattern (\w+) (\w+) with the replacement $2 $1 swaps two words.
How many matches are shown?
The first matches are shown in the list; the total count is written on top.