DEV Community

Dev Nestio
Dev Nestio

Posted on

Regex Tester – Real-Time Regular Expression Testing with Match Highlighting

Regex Tester

A real-time regex testing tool with match highlighting, capture groups, and named groups: devnestio.pages.dev/regex-tester/

Features

  • Real-time matching — results update as you type (80ms debounce)
  • Color-coded highlights — up to 5 colors cycle through matches
  • Capture groups listed — numbered ($1, $2) and named groups
  • Match positions — start and end index for every match
  • Flag toggle pills — click g/i/m/s/u/d to toggle flags instantly
  • Regex error display — clear error messages for invalid patterns
  • Quick reference cheat sheet — \d, \w, \b, lookahead, named groups, etc.
  • Pre-loaded with email regex example

Supported Flags

Flag Meaning
g Global — find all matches
i Case insensitive
m Multiline — ^ and $ match line boundaries
s DotAll — . matches newlines too
u Unicode mode
d Has indices — adds start/end index to groups

Zero-Width Match Protection

Zero-width matches (like \b or (?=x)) can cause infinite loops with global flag. The tool handles this:

while ((m = re.exec(testStr)) !== null) {
  matches.push(m);
  if (m[0].length === 0) re.lastIndex++; // advance past zero-width
}
Enter fullscreen mode Exit fullscreen mode

Named Groups Example

Pattern:  (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
String:   2026-07-01
Groups:   year=2026  month=07  day=01
Enter fullscreen mode Exit fullscreen mode

Try It

devnestio.pages.dev/regex-tester/


Part of the DevNestio developer tools collection.

Top comments (0)