Regex Tester
Test and debug regular expressions with real-time matching.
No matches found
About this tool
Iterate on a regular expression against real sample text and see every match highlighted the instant you change the pattern. Useful when you're cleaning a log file in a hurry, writing an input-validation rule, reaching for a capture group inside sed, or trying to remember whether \d matches just ASCII digits or every Unicode digit class. The tester uses the same ECMAScript regex engine as your JavaScript runtime, with toggles for the common flags — global (g), case-insensitive (i), multiline (m), dotall (s), unicode (u), and sticky (y) — so what matches here will match in your Node.js or browser code. Capture groups are numbered and, if named, called out by name. No server round-trip: paste production-like data without worrying about it being logged, even when that data is full of PII.
Features
- Test regular expressions with real-time matching
- See highlighted matches in your test string
- Support for common regex flags (global, case-insensitive, multiline)
- Instant feedback as you type your pattern
How to Use
- Enter your regular expression pattern
- Type or paste a test string to match against
- Select the regex flags you need
- View highlighted matches and capture groups
Frequently Asked Questions
Do JavaScript regexes match the same way as Python or PCRE?
Mostly, but not exactly. JS lacks look-behind support in some older engines (fine in modern Chromium/Firefox/Safari), uses \b a little differently with Unicode, and treats \d as ASCII-only unless you pass the u flag. Test against the engine you'll run in production.
Why does my pattern match more than I expected?
Regex quantifiers default to greedy — they consume as many characters as possible. Add a ? after the + or * (e.g., .*?) for a lazy match, or anchor the pattern with \b word boundaries. The "highlight every match" view makes over-matching obvious at a glance.
What does the u flag actually do?
It switches the engine into Unicode mode: \u{…} escapes become legal, \d and \w stay ASCII (unless you combine with the v flag), surrogate pairs are treated as a single code point, and invalid escapes throw instead of being silently ignored. Turn it on for anything that touches non-ASCII text.
Should I use regex to parse HTML or JSON?
No — HTML and JSON are context-free; regex is not. Use a proper parser (DOMParser for HTML, JSON.parse for JSON). Regex is right for flat, line-oriented text: log lines, CSV fields you already know are simple, filename patterns, identifier validation.
What's catastrophic backtracking, and why did it freeze my tab?
A pattern like (a+)+ can try every possible split of a string of a's — exponential work. The engine isn't infinite-looping; it's just exploring too many branches. Rewrite the pattern to avoid nested quantifiers (a+ instead of (a+)+) or use a regex linter like safe-regex.
Can I paste secrets into the test string?
Yes — the tester is fully client-side. Nothing leaves your browser, no pattern or input is logged. Credentials, tokens, and personal data are safe to paste in while iterating on a pattern.