DEVELOPER TOOLS

Regex tester

Write a regular expression and see what it matches as you type. It uses your browser’s JavaScript engine, so what matches here matches in your code.

2 matches.

Matches in the text

Match details

  1. [email protected]at 9–24
  2. [email protected]at 28–54

Cheat sheet

.
Any character except a line break
\d \w \s
A digit, a word character, white space
\D \W \S
Anything that is not one of those
[abc] [^abc]
One of these characters; none of them
[a-z]
A character in a range
^ $
Start and end of the text (or line, with m)
\b
A word boundary
a* a+ a?
Zero or more, one or more, optional
a{3} a{2,5}
Exactly three; two to five
a*? a+?
As few as possible (lazy)
(abc)
A group you can refer to as $1
(?<name>abc)
A named group, $<name>
(?:abc)
A group that is not captured
a|b
Either a or b
(?=abc) (?!abc)
Followed by; not followed by
\. \( \\
A real dot, bracket or backslash

What do the flags do?

g (global)
Find every match, not just the first.
i (ignore case)
Treat upper and lower case as the same.
m (multiline)
^ and $ match at the start and end of every line.
s (dot all)
The dot also matches line breaks.
u (unicode)
Treat the pattern as Unicode; enables \p{…} classes.
y (sticky)
Match only at the position where the last match ended.

Will my pattern work in other languages?

This tester uses JavaScript’s rules. The basics are the same in Python, Java, PHP, Go and .NET, but details differ: named groups are written (?P<name>…) in Python, Go has no look-behind or back-references, and flags are set in different ways. Test in the language you will run the pattern in before relying on it.

Why did my pattern get stopped?

Some patterns can match the same text in a huge number of ways, and the engine tries them all before giving up. This is called catastrophic backtracking and it is a real cause of outages. The usual culprit is a repeat inside a repeat, such as (\w+)+ or (a|aa)*. The tester stops after 1.5 seconds so the page stays usable.

Is my text uploaded?

No. Matching runs in your browser, and this page loads no ads.

Related tools

Compare a before and after in the diff checker, tidy an API response in the JSON formatter, or browse all utilities.