Regex Tester
Runs in your browserTest a regular expression against sample text with live matches, capture groups and a replace preview. Runs in your browser.
//g
2 matches
"hello@snaptools.in"at 8 · groups:"hello""snaptools.in""sales@knklabs.com"at 30 · groups:"sales""knklabs.com"
About this tool
Regular expressions fail in ways that are hard to see by reading them: a greedy quantifier swallows more than intended, an unescaped dot matches any character, or a missing global flag returns only the first result. Testing against real sample text turns that guesswork into feedback. This tester uses the browser's own regex engine — the same one your JavaScript will use — so what you see here is what your code will do.
How to use
- Type your pattern without the surrounding slashes.
- Toggle the flags you need — global is on by default so you see every match.
- Paste representative sample text, including the cases you expect to fail.
- Optionally enter a replacement to preview the result; $1 and $2 refer to capture groups.
When to use this tool
- Working out why a validation pattern rejects valid input.
- Extracting fields from log lines or scraped text.
- Building a find-and-replace before running it across a codebase.
- Learning what a regex someone else wrote actually does.
Tips
- Test the failure cases, not just the ones you expect to match — that is where regexes usually go wrong.
- Use non-greedy quantifiers like .*? when matching between delimiters.
- Anchors ^ and $ match string start and end unless the multiline flag is set, when they match each line.
Limitations
- Uses the JavaScript regex engine. PCRE features such as lookbehind variants, atomic groups and recursion behave differently or are unsupported.
FAQ
- Is my text sent anywhere?
- No. The pattern is executed by your browser's regex engine locally. Nothing is transmitted or stored.
- Which regex dialect is this?
- JavaScript's. Most everyday syntax is shared with PCRE, but PCRE-specific features such as atomic groups, recursion and possessive quantifiers do not exist here, and named groups use (?<name>…).
- Why does my pattern only find one match?
- The global flag is off. Without it, matching stops at the first result.