Regex Tester

Regular expressions are famously easy to write wrong and hard to debug by staring at them. A single misplaced quantifier can make a pattern match everything or nothing. This tester highlights matches live as you type your pattern and test string, and includes a quick-reference cheat sheet so you're not tab-switching to look up what \b or (?:...) means mid-task.

//g
Contact us at hello@example.com or support@toolzhq.com for help.
"hello@example.com"index 14
"support@toolzhq.com"index 35

How to use the Regex Tester

  1. Enter your regular expression pattern in the pattern input field.
  2. Toggle the flags you need, such as global, case-insensitive, or multiline.
  3. Paste or type your test string in the text area below.
  4. View highlighted matches, capture groups, and index positions in real time.
  5. Use the built-in cheat sheet for quick reference on regex syntax.

Greedy vs. lazy quantifiers, the most common regex surprise

By default, quantifiers like * and + are greedy. They match as much text as possible. Given the string <b>bold</b> and the pattern <.+>, a greedy match grabs the entire string from the first < to the very last >, not just <b> as most people expect. Adding a ? after the quantifier (<.+?>) makes it lazy, matching the shortest possible string instead. This single fix resolves a huge share of "why is my regex matching too much" problems.

Frequently asked questions

Does it support named capture groups?

Yes, along with standard numbered groups, non-capturing groups, lookaheads, and lookbehinds. The highlighting shows which part of the match came from which group.

Which regex flavor does it use: PCRE, JavaScript, or Python?

It follows JavaScript's regex engine, since that's what runs in the browser; behavior for lookbehind support and some edge cases can differ slightly from Python's re module or PCRE, so double-check flavor-specific behavior if you're writing a pattern for a non-JS environment.

Why does my pattern work here but fail in my actual code?

Usually a flags mismatch (case-sensitivity, multiline mode, global matching) or a difference in how the host language expects backslashes to be escaped in a string literal. Check both before assuming the pattern itself is wrong.