Regex Tester & Debugger
Test and debug regular expressions online with live match highlighting. Toggle global and case-insensitive flags and see every match as you type. Free regex tester.
About this tool
Write a regular expression and watch its matches highlight live in your sample text, with global and case-insensitive flags a click away. Developers iterate on validation patterns here before committing them, because a regex that looked right and a regex that is right are rarely the same thing on the first try.
How to Test a Regular Expression
- 1
Paste representative sample text — real data, not idealized examples, since real data is where patterns fail.
- 2
Type your pattern and toggle flags: global to find every occurrence, case-insensitive to ignore letter case. Matches highlight in the text instantly as the pattern changes.
- 3
Refine until the highlights cover exactly what you intend — no misses, no overreach — then copy the finished pattern into your code.
Why Test Regex with Wrklyst
- Sample Data Stays Local
- Testing against production-like strings is safe because matching runs in your browser — real emails or IDs in your samples aren't shipped anywhere.
- Feedback per Keystroke
- Highlighting updates live as you edit the pattern, collapsing the write-run-check loop into pure immediate feedback.
- No Environment Needed
- Iterate on a pattern without a REPL, test file, or IDE — just the pattern, the text, and the truth.
Regex Craft
- Include should-NOT-match examples in your sample text — overmatching is the bug you won't see otherwise.
- Build incrementally: get a small piece matching, extend, verify, repeat. Debugging a full-formed pattern is misery.
- Anchor with ^ and $ when validating whole values, or 'abc123' will pass your number-only check.
- Comment the intent next to any non-trivial pattern in code — future-you reads English better than regex.
Frequently asked questions
Why does my regex work here but fail in my code?
Usually escaping or dialect. When a pattern lives inside a string literal, backslashes need doubling (\d becomes \\d in many languages). Dialects also diverge: this tester uses JavaScript regex, and features like lookbehind or named groups vary across Python, Java, and PCRE. Test the concept here, then adapt syntax to your runtime.
What do the global and case-insensitive flags change?
Without global, matching stops at the first occurrence — with it, every occurrence highlights, which is what you want for find-all and replace operations. Case-insensitive makes letters match regardless of case, so /error/i catches Error and ERROR. Most real-world patterns want both on while exploring.
Why does my pattern match too much?
The usual suspects: an unescaped dot matching any character, and greedy quantifiers — .* consumes as much as possible, famously swallowing everything between the first and last quote on a line. Escape literal dots as \. and reach for lazy quantifiers (.*?) or negated classes ([^"]*) to match minimally.
Should I validate emails with a regex?
Only loosely. The RFC's actual grammar is infamously beyond practical regex, and strict patterns reject real addresses. The pragmatic standard is [email protected] as a sanity check, with a confirmation email as the true validation. Save your regex rigor for formats with clean grammar, like postal codes or IDs.