How to use the regex tester
- Type your pattern without the surrounding slashes, and tick the flags you need.
- Paste some test text. Matches are highlighted as you type, and capture groups are listed in a table.
- Tick "Preview a replace" to see the text after a find-and-replace, using $1 or $<name> for groups.
Quick reference
| Pattern | Matches |
|---|---|
\d \w \s | A digit; a letter, digit or underscore; a space, tab or line break |
. | Any character except a line break (with the s flag, line breaks too) |
[abc] [^abc] | One of a, b or c; any character except those |
* + ? {2,4} | 0 or more; 1 or more; 0 or 1; 2 to 4 of the thing before |
^ $ \b | Start; end (of each line with the m flag); a word boundary |
(…) (?<name>…) (?:…) | A numbered group; a named group; a group that isn't captured |
a|b | a or b |
Worked example
Frequently asked questions
Which regex flavour does this use?
JavaScript's, as built into your browser. Most patterns work the same in Python, Java, PHP and .NET, but some features differ, such as lookbehind support and how named groups are written. Test in your own language before relying on a pattern.
Why did it say "stopped after 1 second"?
Some patterns, especially nested repeats like (a+)+, can take an extremely long time on text that almost matches (called catastrophic backtracking). We run the match in the background and stop it after a second so the page doesn't freeze. The same pattern could slow down a real program, so it's worth rewriting.
Is my text sent anywhere?
No. Matching happens in your browser.