Regex Tester

Test and validate JavaScript regular expressions in real time.

Write a pattern, paste sample text, and see matches highlighted instantly. Capture groups are listed separately so you can verify which parts of the pattern caught which substrings before pasting it into your code.

Common use cases: extracting fields from log lines, validating user input shapes, sanity-checking find-and-replace rules before running them across a codebase, and understanding what a regex from Stack Overflow actually does on real data.

g=global, i=case-insensitive, m=multiline, s=dotall

Frequently asked questions

Which regex flavour does this tester use?
JavaScript (ECMAScript) regex, the same flavour your code will see in the browser and in Node.js. It's close to PCRE for everyday patterns but has small differences: no named groups before ES2018, no lookbehind in older runtimes, slightly different Unicode behaviour without the u flag.
What do the flags actually do?
g finds all matches instead of just the first. i makes it case-insensitive. m makes ^ and $ match at every line, not just the start/end of the string. s lets . match newlines. u turns on full Unicode awareness — recommended for anything with non-ASCII text.
Why is my pattern matching too much or too little?
Three usual suspects: greedy quantifiers (.* matches as much as possible — try .*?), forgetting to escape special characters, or forgetting the g flag when you expected all matches.
What is catastrophic backtracking?
A pattern with nested quantifiers (e.g. (a+)+$) can take exponential time on inputs that nearly match. If a pattern hangs your browser tab, that's the cause. Rewrite the pattern to avoid ambiguous backtracking.
Can I use this to validate emails or URLs?
You can, but proper validators usually beat regex for those formats. RFC 5322 emails alone need a 6000-character regex. For emails, check the syntax loosely and then send a confirmation. For URLs, use the URL constructor.