Test and debug regular expressions with real-time matching and highlighting.
Pattern
//
Characters
.Any character
\dDigit [0-9]
\DNon-digit
\wWord char [a-zA-Z0-9_]
\WNon-word char
\sWhitespace
\SNon-whitespace
Quantifiers
*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,m}Between n and m
*?Lazy (non-greedy) *
+?Lazy (non-greedy) +
Anchors
^Start of string/line
$End of string/line
\bWord boundary
Groups & Lookaround
(...)Capture group
(?:...)Non-capture group
(?=...)Lookahead
(?!...)Negative lookahead
(?<=...)Lookbehind
\1Back-reference
Character Classes
[abc]Any of a, b, c
[^abc]Not a, b, or c
[a-z]Range a to z
|Alternation (or)
Test String
Replace with
Matches: 0Time: 0 ms
Match Details
Enter a pattern and test string to see matches.
About This Tool
Write a regular expression here and see instantly what it matches in your test string. Matches are highlighted in the text, every match is listed with its details below, and an invalid pattern shows its syntax error straight away. No install, no sign-up.
This is for the moment before you put a pattern into real code: validating emails and phone numbers in a form, pulling order numbers or dates out of text, cleaning up a log file, writing URL rewrite rules, or setting up a bulk find-and-replace in your editor. Instead of re-running your program each time, you refine the pattern here until it is right.
Five ready-made patterns for email, URL, phone, IP and date load with their own sample text. The g, i, m, s and u flags toggle with a click, a quick reference of regex tokens sits one button away, and replace mode previews the final result. Your pattern and text never leave your device.
Frequently Asked Questions
How do I test a pattern?
Type the regex between the two slashes in the Pattern box and paste your text into Test String. Matches highlight immediately, and below you get the match count, the execution time and the details of every match.
I do not know regex. Where do I start?
Press one of the Email, URL, Phone, IP or Date buttons. Both the pattern and a sample text load, with some valid and some invalid examples so you can see exactly what the pattern catches and what it does not. Then edit it from there.
What does the cheat sheet do?
The "Cheat Sheet" button opens a table of common regex tokens. Click any row and that token is inserted into the pattern box, so you do not have to memorise the syntax.
What do the g, i, m, s and u flags do?
g finds every match instead of just the first, and is on by default. i treats upper and lower case as the same. m makes ^ and $ match the start and end of each line rather than the whole text. s lets the dot match newlines too. u runs the pattern in unicode mode, which you need for non-Latin text and emoji.
Why do I only get one match?
The g flag is probably off. Without it only the first match is returned. Click the g button to get them all.
How do I preview a replacement?
Press "Replace" in the toolbar to open the "Replace with" box. Whatever you type previews the final text underneath. Use $1, $2 and so on to reference capture groups.
What are capture groups and where do I see them?
Anything you put in parentheses is a group and its value is extracted separately. For example (\w+)@(\w+) against user@host gives two groups, user and host. Each group is listed under its match in the details list.
How do I find where a match sits in the text?
Click that match's row in the details list; the test string scrolls to it and the fragment is highlighted. The numeric position of each match is shown next to it as well.
How do I copy the results?
"Copy All" in the toolbar copies every match at once. For a single one, use the copy button on that row.
Can I send someone my pattern?
Yes. The pattern, flags, test string and replacement are kept in the page address, so copying the URL from the address bar and sending it is enough. The other person opens exactly the same state.
My text is huge. Is there a limit?
Results are listed up to the first 1000 matches so a heavy pattern cannot lock up the page. That is far more than enough to test a pattern; if you are working on a big file, paste a smaller sample of it here.
My pattern produces empty matches. Why is nothing shown?
Zero-length matches, such as \d* which can match no digits at all, are skipped in the list because there is nothing to show in the text. Change the quantifier from * to + to see real results.
Will this regex work in my programming language?
Common patterns are nearly identical everywhere, but each language has its own syntax details. What you write here is JavaScript syntax; in PHP, for instance, the pattern usually has to be wrapped in delimiters with the flags after them.
Is my pattern or text stored?
No. Everything runs on this page and neither the pattern nor the text leaves your device. The only way it is shared is if you copy the page URL yourself.