Skip to content
Image
PDF
Text
Developer
Calculators
Language
Theme

Regex tester

Type a pattern and some text. You see every match, every group and the replace result right away.

Examples:

Type a pattern and some text. Matches show up as you type.

Explain the pattern

Type a pattern to see what each part does.

Cheat sheet
.
Any character except a line break
\d \w \s
Digit, word character, whitespace
\D \W \S
Not a digit, not a word character, not whitespace
[abc]
One of a, b or c
[^abc]
Any character except a, b and c
[a-z]
One character from a to z
^ $
Start and end of the text (of a line with m)
\b
Word boundary
* + ?
0 or more, 1 or more, 0 or 1 time
{3} {2,5}
Exactly 3 times, 2 to 5 times
*? +?
As few as possible
(abc)
Group, saved as $1
(?<name>abc)
Named group, saved as $<name>
(?:abc)
Group that is not saved
a|b
a or b
(?=abc) (?!abc)
Followed by abc, not followed by abc
(?<=abc) (?<!abc)
After abc, not after abc
\1 \k<name>
The same text as group 1 or group name
\. \* \(
A real dot, star or bracket

This tester uses the JavaScript regex engine of your browser. Some features of PCRE, PHP or Python, like possessive quantifiers or (?P<name>...), do not exist here.

Runs in your browser. Your files are not uploaded anywhere.

How to use it

  1. 1Type your pattern, or tap one of the examples.
  2. 2Switch flags on or off, for example g for all matches or i to ignore case.
  3. 3Paste your test text. Matches and groups are highlighted as you type.
  4. 4Switch on Replace to preview the result, then copy it or copy a link to share.

Questions and answers

Which regex engine does this tester use?

The JavaScript engine of your browser, the same as in JavaScript, TypeScript and Node.js. A pattern that works here works the same way in your JavaScript code.

Will my pattern work in PHP, Python or Java?

Mostly yes for the basics: classes, groups, quantifiers and lookarounds. Differences: JavaScript has no possessive quantifiers (a++), no atomic groups and no \A or \Z. Python writes named groups as (?P<name>...) and PHP uses delimiters like /.../i. Test special features in the target language too.

Why does the tool stop my pattern after half a second?

Some patterns, like (a+)+$, try a huge number of ways to match when the text almost fits. This is called catastrophic backtracking and can freeze a page or a server. The tool stops it and keeps the page responsive. Make the pattern more specific, for example a+ instead of (a+)+.

Is my text sent anywhere?

No. Matching runs in your browser. The share link puts the pattern and text in the part after #, which browsers do not send to the server.

How do I use groups in the replacement?

Write $1, $2 for numbered groups, $<name> for named groups and $& for the whole match. Without the g flag only the first match is replaced.

More tools