How to use the regex tester
- Type your regular expression in the first box, or choose one of the examples.
- Paste the text you want to test. Matches are highlighted as you type.
- Tick Replace matches to preview a find-and-replace.
Regex cheat sheet
| Pattern | Matches |
|---|---|
. | Any single character |
\d, \w, \s | A digit, a word character (letter, digit or _), a space |
\D, \W, \S | The opposite of each of those |
[abc], [^abc], [a-z] | One of a, b or c; anything except them; any letter from a to z |
^, $ | The start and the end of the text (or of each line with the m flag) |
\b | The edge of a word |
*, +, ? | Zero or more, one or more, zero or one of the thing before |
{3}, {2,5} | Exactly three; between two and five |
(abc) | A capture group, available as $1 when replacing |
(?<name>abc) | A named capture group |
a|b | Either a or b |
\., \? | A real dot or question mark (the backslash removes the special meaning) |
The flags
- g (global) finds every match instead of stopping at the first.
- i (ignore case) treats capital and small letters as the same.
- m (multiline) makes
^and$match at the start and end of each line. - s (dot all) lets
.match line breaks too. - u (Unicode) handles emoji and accented letters correctly and enables
\p{…}.
Which kind of regex is this?
The tester uses your browser's own JavaScript engine, so results match what you will get in JavaScript and TypeScript, and in most cases in Python, PHP, Java and others. A few features differ between languages, such as lookbehind support and the syntax for named groups, so test in your target language before relying on an advanced pattern.
Your text stays on your device
Everything happens in your web browser. Nothing you type or paste is sent to a server or stored, so it is safe to use with private notes, passwords, keys and work documents. There is no sign-up and no limit.
Frequently asked questions
How do I test a regular expression?
Type the pattern in the first box and your text below it. Every match is highlighted as you type.
What are capture groups?
Parts of the pattern in brackets. Each one is listed under its match, and you can use them as $1, $2 and so on when replacing.
Why is only one match highlighted?
The g flag is off. Tick “g: find all” to find every match.
Is my text uploaded?
No. The pattern runs in your browser.