Regex Tester

Test regular expressions with live match highlighting, match positions, and capture groups.

//g
g=global i=case-insensitive m=multiline s=dotall u=unicode

Example Patterns

Deep Dive

Test regular expressions against sample text in real time with live match highlighting. Supports all JavaScript regex flags (`g`, `i`, `m`, `s`, `u`), named capture groups, and displays each match's index and captured groups. No data leaves your browser.

Who uses this?

  • Building and testing an email validation regex
  • Extracting dates or phone numbers from a block of text
  • Debugging a complex search-and-replace pattern
  • Learning regex syntax interactively

Examples

Match email addresses

Input

Contact us at hello@karuvilab.com or support@example.org

Output

Matches: hello@karuvilab.com, support@example.org
Extract digits

Input

Order #4521 ships in 3 days

Output

Matches: 4521, 3

Common Errors & Fixes

Regex throws 'Invalid regular expression'

Check for unmatched parentheses, brackets, or unescaped special characters in the pattern.

Pattern only matches once even with the global flag

Ensure the `g` flag is enabled. Without it, `RegExp.exec` and `String.match` return only the first match.

Catastrophic backtracking causes the browser to hang

Simplify nested quantifiers (e.g., `(a+)+`). These can cause exponential time complexity on certain inputs.

Expert FAQ

Which regex flavor does this use?

JavaScript's built-in `RegExp` engine. Most common patterns are compatible, but features like lookbehinds require a modern browser (Chrome 62+, Firefox 78+).

Why does my regex match nothing?

Check that special characters (`.`, `*`, `+`, `?`, `(`, `)`) are escaped with a backslash if you want them treated literally.

What are flags and when do I use them?

`g` finds all matches (not just the first), `i` ignores case, `m` makes `^` and `$` match line boundaries, `s` makes `.` match newlines.

Can I use named capture groups?

Yes. Use `(?<name>...)` syntax. Named groups are displayed alongside numeric groups in the match list.

Alternatives

regex101.comregexr.comRegExBuddy