Regex Tester: Test Regular Expressions Online
This regex tester checks a regular expression against your text and highlights every match as you type. See match positions and capture groups in a table, switch flags on and off, start from common patterns for emails, URLs and dates, and preview a replace before you put the pattern in your code.
| # | Match | Index | Groups |
|---|
Everything runs in your browser. Nothing you enter is sent to or stored on our server.
Quick answer: Type a pattern in the first box and your text in the second. Every match is highlighted, and the table lists each match, where it starts and what each capture group caught. The tool uses JavaScript’s regex engine, the same one used in browsers and Node.js.
How to use the regex tester
- Enter a regular expression without the surrounding slashes, for example
d{3}-d{4}. - Tick the flags you need: g for all matches, i to ignore case, m so ^ and $ match at each line, s so a dot also matches line breaks, and u for full Unicode.
- Paste the text to test. Matches are highlighted live.
- Optionally type a replacement to preview the result of
text.replace(), using $1, $2 for capture groups.
Regex cheat sheet
| Pattern | Matches |
|---|---|
. | Any character except a line break |
\d \w \s | A digit, a word character (letter, digit, underscore), whitespace |
\D \W \S | The opposite of each of the above |
[abc] [^abc] [a-z] | One of a, b or c; anything except them; a lowercase letter |
^ $ | Start and end of the text, or of each line with the m flag |
\b | A word boundary |
* + ? | 0 or more, 1 or more, 0 or 1 of the previous item |
{3} {2,5} | Exactly 3, or between 2 and 5 |
*? +? | Lazy versions that match as little as possible |
(abc) (?:abc) | Capturing group; non-capturing group |
(?<name>abc) | Named group |
a|b | a or b |
(?=x) (?!x) | Followed by x; not followed by x |
Common mistakes
- Forgetting to escape: characters like
. * + ? ( ) [ ] { } | ^ $ \have special meanings. Write\.to match a real dot. - Greedy matching:
<.*>matches from the first < to the last > on the line. Use<.*?>to stop at the first. - Double escaping in code: inside a JavaScript or Java string, a backslash must be written twice, so
\dbecomes"\\d".
Other engines such as PCRE (PHP), Python and Java support nearly the same syntax, with small differences in lookbehind and named groups. To change text in bulk with a pattern, use find and replace. Format API responses with the JSON formatter.
FAQ
Why does my pattern match nothing?
Check the error message under the pattern box, make sure special characters are escaped, and try the i flag in case the letter case differs.
Is my text uploaded?
No. Matching runs entirely in your browser.
More free tools
See all of them on the QuickOnlineTips free online tools page and play our free online games.
