Free online tool
Regex Tester
Write a regular expression and see live matches in your sample text.
- hi@example.comat 14
- support@toolnest.devat 32
What regex is good at
Regular expressions describe patterns of text: an email address, a phone number, a date, or a snippet of code that starts a certain way. They're built into every major programming language and most text editors, so the pattern you write here works almost anywhere. The catch is that regex has a steep learning curve, and it's easy to write patterns that are subtly wrong.
Common flags
g finds all matches instead of stopping at the first. i makes matching case-insensitive. m lets ^ and $ match at line boundaries. s lets . match newlines. Combine them as needed — for example gim for a global, case-insensitive, multi-line match.
+Which regex flavor is this?
JavaScript (ECMAScript). Most patterns are portable, but lookbehinds and Unicode property escapes may differ in other languages.
+How do I match a literal dot?
Escape it with a backslash: \.
Watching a pattern match before it ships to production
Regular expressions are compact but unforgiving — a single misplaced quantifier changes what matches, and the failure mode is often silent rather than a thrown error, which is exactly why testing against real sample text before deploying a pattern saves debugging time later.
A live tester with instant highlighting of matches and capture groups turns a trial-and-error loop that would otherwise mean editing code, saving, and re-running a script into something you can iterate on in seconds, which matters a lot when a pattern needs a dozen small adjustments before it's actually correct.
Greedy quantifiers grab more than you expect
A pattern like <.+> against the string <b>bold</b> will match the entire string from the first < to the last >, because + is greedy by default and consumes as much as possible before backtracking. Switching to <.+?> makes it lazy, matching the shortest possible span instead, which is usually what people actually want when parsing tag-like structures, though for real HTML a proper parser beats regex every time.
Catastrophic backtracking is a real production incident
Nested quantifiers like (a+)+ against a long string of a characters followed by a non-matching character can cause the regex engine to try an exponential number of ways to backtrack before giving up, freezing the thread for seconds or minutes on input that looks perfectly innocent. This has taken down real servers when user input hit a vulnerable pattern in a validation regex, so testing against pathological inputs, not just happy-path examples, is worth the extra minute.
Flags change more than case sensitivity
The global flag affects whether .test() and exec() maintain state between calls via lastIndex, a frequent source of bugs where a regex that matches on the first call mysteriously fails on the second. The multiline flag changes what ^ and $ anchor to, and the dotall flag changes whether . matches newlines — testing a pattern here with the exact flag combination your code will use catches these mismatches before they reach a code review.
Capture groups versus non-capturing groups
Parentheses create a capture group by default, which stores the matched substring for later reference via backreferences or a match result array, but wrapping alternation purely for grouping purposes — without needing the matched text — is better done with a non-capturing group written as (?:...), since it avoids cluttering the results array and marginally improves performance on complex patterns evaluated many times over large input.
Lookahead and lookbehind for context without consuming text
A pattern like (?<=\$)\d+ matches digits only when preceded by a dollar sign, without including the dollar sign itself in the match, which is what a lookbehind assertion is for. Lookahead works the same way but checks what follows instead of what precedes. Both are zero-width, meaning they don't advance the match position or get included in the captured text, which is exactly what makes them useful for validating context — like requiring a password to contain a digit somewhere — without needing to capture that digit specifically.
People also search for
- regex tester online
- regular expression debugger
- test regex pattern
- regex lookahead lookbehind
- regex greedy vs lazy
- catastrophic backtracking regex
- regex capture groups explained
- regex cheat sheet tool