Regex Tester
Test your regex patterns. Cry about your regex patterns. Both valid uses.
Contact us at hello@scratchpad.page or support@scratchpad.page for help.
What this does
Type a regex pattern, paste some test text, see what matches. Matches highlight inline so you can see exactly where they land in context. Capture groups show up in the details panel with their index, content, and position. The pattern runs live as you type, so you get instant feedback on whether your regex does what you think it does.
The flags matter and here's what each one does. g (global) finds all matches, not just the first one. Without it, the regex stops after the first hit. i (case-insensitive) makes /hello/i match "Hello", "HELLO", and "hElLo". m (multiline) changes ^ and $ to match the start and end of each line instead of the entire string. Useful when your test text has multiple lines and you want to anchor to line boundaries. s (dotAll) makes . match newline characters too, which it doesn't by default. Toggle them on and off with a click.
Some patterns you'll reach for constantly. Email (simplified): [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. URLs: https?://[^\s]+. IPv4 addresses: \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b. Dates in YYYY-MM-DD format: \d{4}-\d{2}-\d{2}. These are starting points, not production-grade validators. Email validation with regex is famously a losing battle, and the technically correct pattern is over 6,000 characters long. Don't go there.
Capture groups let you extract specific parts of a match. Wrap part of your pattern in parentheses and it becomes a group. /(\d{4})-(\d{2})-(\d{2})/ on "2026-03-20" gives you three groups: "2026", "03", "20". Named groups work too: /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/. The details panel shows all captured groups for every match.
Characters that need escaping: . * + ? ^ $ { } [ ] ( ) | \. These all have special meaning in regex. If you want to match a literal dot, write \. not . (which matches any character). Forgetting to escape is the most common regex bug. If your pattern matches way more than expected, check for unescaped special characters first.
A word about catastrophic backtracking (ReDoS). Certain patterns with nested quantifiers like (a+)+$ can take exponentially long to fail on certain inputs. This tool runs your regex in a Web Worker with a timeout, so a bad pattern won't freeze the page. But if you see a timeout warning, your pattern probably needs restructuring. Avoid nesting quantifiers ((a*)*, (a+)+) and use atomic grouping or possessive quantifiers where your language supports them.
This uses the native JavaScript regex engine, which means it's ECMAScript regex. If you're writing patterns for Python, PHP (PCRE), or Java, there are small differences. JS doesn't support lookbehind in older engines (modern browsers do), doesn't have \p{L} without the u flag, and handles backreferences slightly differently. For most common patterns, it won't matter. For edge cases, test in the target language too. Your patterns and test strings never touch a server, so feel free to test against real data.