Regex Tester & Explainer
Test a regular expression against your own text, see every match and capture group highlighted, get each piece of the pattern explained, and check what JavaScript, PCRE and RE2 actually support. Everything runs in your browser.
Also available as a desktop app for Windows.
About this tool
A regular expression is a tiny language for describing text patterns, and almost every tool that touches text speaks it — search boxes, log filters, code editors, database queries. It is also famously easy to write something that looks right and matches the wrong thing. The fix is not to think harder; it is to watch it run against text you already understand.
This page does that in one place. Type a pattern, pick your flags, paste some text, and every match is highlighted in place while every capture group is listed underneath with its position. Below that, the pattern is split into its individual pieces and each one is explained in plain words — so you can see what \b, (?<=…) and a lazy quantifier actually do, without consulting a cheat sheet.
The third section covers something most testers ignore: the same pattern does not behave identically in every engine. A regex that works perfectly in a browser may be rejected by RE2 on a server, or silently behave differently. The comparison table lists the features where the engines genuinely diverge, so a regex that works locally is less likely to surprise you in production.
Everything is computed on your own device. There is no upload step and no server doing the matching, which matters when the text you are testing is a customer record or a line from a production log.
Frequently asked questions
- Why did my pattern not finish?
- Some patterns can backtrack explosively. (a+)+$ against a long run of the letter a is the classic example: each extra character roughly doubles the work, so forty characters is already a trillion steps. This tester runs your pattern in a separate worker and stops it after a short timeout, so the page stays usable. If you see that message, the pattern itself is the problem — usually nested quantifiers, or two quantifiers in a row that can match the same text.
- What is the difference between greedy and lazy?
- A quantifier is greedy by default: it takes as much as it can and then gives characters back until the rest of the pattern fits. Adding ? makes it lazy, so it takes as little as possible and grows only when it has to. Against <b>bold</b>, <.+> matches the whole string, while <.+?> matches just <b>. Both are correct — they answer different questions.
- Does \w match accented letters or Chinese characters?
- In JavaScript, no — unless you set the u flag, \w means exactly the ASCII letters, digits and underscore. Chinese, Cyrillic, accented Latin and emoji are all outside it. If you need to treat any letter in any script as a word character, use \p{L} with the u flag, or list the ranges you actually want.
- What do the lookahead and lookbehind groups do?
- They let you require something without consuming it. \d+(?= dollars) matches the number in "250 dollars" but not the word dollars — the match is just 250. Lookbehind does the same backwards: (?<=\$)\d+ takes the number after a dollar sign without including the sign. They are the standard way to say "only if surrounded by this", and they are exactly what RE2 cannot do.
- Why does my pattern give only one result?
- Because the g flag is off. Without g, a regular expression stops at the first match — that is the default in JavaScript and in most languages. Turn on g and it will keep going. If you came here from a search box that returned everything, that box was setting g for you.
- Is the text I paste sent to a server?
- No. The matching happens in your browser, in a worker thread on your own machine. Nothing you type is transmitted or logged anywhere. That is deliberate: production log lines and customer data are the most common things people test regexes against, and neither belongs on someone else’s server.
- What does the sticky flag y do?
- It anchors each match to the exact position where the previous one ended, instead of searching forward from there. It is how you walk through a string token by token and get told when the pattern stops fitting. PCRE has the same idea under a different name, \G, which is why the comparison table lists them together.