Regex Tester
Test JavaScript regular expressions live, see every match and capture group, and preview replacements.
Type a pattern to see matches.
Was this tool helpful?
Debug Regular Expressions Without Guesswork
Regular expressions are compact and easy to get subtly wrong. Seeing every match highlighted in real text, with the groups each match captured, is the fastest way to find out why a pattern matches too much or too little.
How to Test a Regular Expression
- Enter a pattern. Type your regular expression between the slashes. Errors are shown straight away.
- Choose flags. Toggle g, i, m, s and u to change how the pattern matches.
- Add test text. Paste the text to search. Matches are highlighted as you type.
- Inspect and replace. Check each match and its groups in the table, and turn on Replace to preview a substitution.
Patterns Worth Bookmarking
- Email (practical): [\w.+-]+@[\w-]+(?:\.[\w-]+)+
- ISO date: \d{4}-\d{2}-\d{2}
- Whole word: \bword\b
- Trim whitespace: ^\s+|\s+$
- Hex colour: #(?:[0-9a-fA-F]{3}){1,2}\b
Frequently Asked Questions
Which regex flavour does this tester use?
It uses your browser's JavaScript (ECMAScript) regular expression engine, so results match what RegExp, String.match and String.replace do in JavaScript and Node.js. Other flavours such as PCRE or Python differ in a few features, like lookbehind support in older engines and possessive quantifiers.
What do the flags mean?
g finds all matches instead of the first; i ignores case; m makes ^ and $ match at the start and end of each line; s lets . match newline characters; u turns on full Unicode matching, which you need for \p{…} property escapes.
How do I use capture groups in a replacement?
Refer to numbered groups as $1, $2 and so on, and named groups as $<name>. $& inserts the whole match. For example, replacing (\w+)@(\w+) with $2 at $1 swaps the two parts.
Why did my pattern time out?
Some patterns backtrack catastrophically: nested quantifiers like (a+)+ or (.*)* can take exponential time on certain inputs. The tester runs your pattern in a separate thread and stops it after one second so the page never freezes. Rewrite the pattern to remove the nested repetition.
Is my test text sent anywhere?
No. Matching runs entirely in your browser in a Web Worker. Nothing you type is uploaded.