RegEx Sandbox
Test regular expressions
Quick reference
Characters
| . | Any character except a line break |
| \d \w \s | Digit, word character, whitespace |
| \D \W \S | The opposite of each |
| [abc] | a, b or c |
| [^abc] | Anything except a, b or c |
| [a-z] | A range of characters |
Quantifiers
| * | Zero or more |
| + | One or more |
| ? | Zero or one |
| {3} {3,} {3,5} | Exactly 3, 3 or more, 3 to 5 |
| *? +? | Lazy: as few as possible |
Anchors
| ^ $ | Start and end of text (or line with m) |
| \b \B | Word boundary, not a word boundary |
Groups
| (abc) | Capture group |
| (?:abc) | Group without capturing |
| (?<name>abc) | Named group |
| \1 \k<name> | Repeat what a group matched |
| a|b | a or b |
Lookaround
| (?=abc) (?!abc) | Followed by, not followed by |
| (?<=abc) (?<!abc) | Preceded by, not preceded by |
Questions
How do I test a regular expression?
Type your pattern, paste the text you want to search, and every match is highlighted as you type.
What does my regex mean?
The "What this pattern does" panel explains your pattern in plain English, piece by piece. The quick reference covers common symbols.
Why does it say the pattern is taking too long?
Some patterns can take a very long time on certain text. The tool stops them so your browser does not freeze. Try making the pattern more specific.