Regex Tester

Test a regular expression against sample text with live match highlighting.

Overview

Tests, evaluates, and debugs JavaScript regular expressions in real time with syntax highlighting, flag toggles, and capture group breakdowns.

Formula & Calculation Method

Matches = RegExp(Pattern, Flags).exec(Target_Text)

Evaluates search patterns with standard PCRE / ECMAScript flags: global (g), case-insensitive (i), multiline (m), dotAll (s), and unicode (u).

Worked Example: Email Validation Regex Pattern

Inputs: Pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ | Target: 'user@example.com'

  • Evaluate username character classes before the @ symbol.
  • Validate domain host and subdomains.
  • Validate top-level domain suffix (minimum 2 characters).
  • Result: Match found (Valid email format).

Summary: Pattern Validated | 1 Full Match Found | Zero Syntax Errors

Common Use Cases

  • Form Input Validation: Test regex rules for validating phone numbers, zip codes, passwords, and email addresses.
  • Log Scraping: Extract timestamp patterns, IP addresses, and HTTP status codes from web server log files.
  • Search & Replace Workflows: Formulate capture group replacement strings ($1, $2) for code refactoring.

Frequently Asked Questions

What is catastrophic backtracking in regular expressions?

A performance pitfall where an ambiguous regex pattern forces the regex engine to explore millions of possible match permutations, hanging the CPU.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +) match as much text as possible; lazy quantifiers (*?, +?) match as little text as necessary.

What does the 'm' flag do in regex?

The multiline flag causes ^ and $ to match the start and end of each individual line, rather than the entire input string.

Related Calculators & Tools