Regex Tester
Type a regular expression and some text to see every match and capture group highlighted as you type, or try a replacement. Patterns that would freeze the page are stopped.
Try an example
Matches
Type a pattern to see what it matches.
Quick reference
\d- A digit, 0 to 9
\w- A letter, digit or underscore (English letters only)
\s- A space, tab or line break
.- Any character but a line break (with s, any at all)
^- Start of the text (with m, of each line)
$- End of the text (with m, of each line)
\b- The edge of a word
*- The thing before, any number of times, even none
+- The thing before, once or more
?- The thing before, or nothing; after * or +, as few as possible
{n,m}- The thing before, from n to m times
[abc]- Any one of a, b or c
[^abc]- Any character except a, b or c
a|b- Either a or b
(…)- A group: repeats as a whole, and its part of the match is $1
(?<name>…)- A group with a name, used as $<name>
(?:…)- A group without a number
\1- The same text that group 1 matched
(?=…)- Followed by …, which isn't part of the match
(?!…)- Not followed by …
(?<=…)- After …, which isn't part of the match
(?<!…)- Not after …
How to use it
- 1Type your pattern without the slashes, and tick the flags you need, such as g for every match or i to ignore case.
- 2Paste the text to test. Matches are highlighted and listed with their position and groups as you type.
- 3To replace, choose Replace and type the replacement: $1 or $<name> puts in a group, $& the whole match.
- 4Not sure where to start? Press one of the examples, such as Indian mobile number or PIN code.
Frequently asked questions
Which regex flavour does this tester use?
JavaScript's, exactly as your browser's RegExp runs it, so a pattern that works here works the same in JavaScript and TypeScript code. Python, PHP, Java and .NET mostly agree, but differ in places such as lookbehind, named groups and flags.
Why does my regex freeze the page or time out?
Some patterns, like (a+)+$, make the engine try a vast number of ways to match before it gives up: this is called catastrophic backtracking. Here every test runs in the background and is stopped after 1 second, so the page never freezes. Make the inner part match in only one way, for example a+$ instead of (a+)+$.
How do I use a capture group in the replacement?
Write $1 for the first group, $2 for the second, and $<name> for a group named with (?<name>…). $& puts in the whole match and $$ a dollar sign. In the date example, $<year>-$<month>-$<day> turns 26/01/1950 into 1950-01-26.
What is a regex for an Indian mobile number?
Press Indian mobile number in the examples: (?<!\d)(?:\+91[\s-]?|0)?[6-9]\d{4}[\s-]?\d{5}(?!\d) finds 10-digit numbers starting with 6, 7, 8 or 9, with or without +91 or 0 in front and a space in the middle.
Is my text sent anywhere?
No. The pattern and text never leave your browser, and nothing is saved. You can test up to 100,000 characters of text at a time, and the first 1,000 matches are listed and highlighted.
Related tools
- JSON Formatter and ValidatorFormat, minify and validate JSON, with any mistake shown by its line and column.
- Base64 Decode and EncodeDecode or encode Base64 text and files, with Hindi and emoji kept intact.
- JWT DecoderDecode a JSON Web Token, read its claims and expiry, and verify its signature.
- UUID GeneratorMake random v4 or time-ordered v7 UUIDs, one or thousands at once, and check any UUID.