Regex Tester

Test JavaScript regular expressions, flags, match positions, capture groups, and highlighted results.

Status

Valid

Matches

2

Expression

/INV-\d{4}-\d{3}/m

Regular expression

Test a JavaScript regular expression against sample text.

Test text

Highlighted result

Invoice INV-2026-001 was paid on 2026-06-27.
Contact billing@example.com for details.
Invoice INV-2026-002 is pending.

Match list

  1. INV-2026-001at index 8
  2. INV-2026-002at index 94

Related calculators

What is the regular expression tester?

This regex tester lets users type a regular expression pattern and immediately see matching results in sample text. It is useful for frontend form validation, backend log extraction, API parsing, QA test cases, data cleaning, system configuration, and learning regex syntax.

Regex syntax covered by the guide

Matching, quantifiers, anchors, and groups

  • The dot . matches any one character except a newline; a.c matches abc, aXc, and a1c.
  • \\d matches digits 0 to 9, \\w matches word characters, and \\s matches whitespace; uppercase versions \\D, \\W, and \\S invert the meaning.
  • Quantifiers include * for 0 or more, + for 1 or more, ? for 0 or 1, {n} for exactly n, and {n,m} for n to m repetitions.
  • ^ matches the start, $ matches the end, and \\b matches a word boundary.
  • Capturing groups use (pattern) and can be referenced as $1 or $2; non-capturing groups use (?:pattern), and named groups use (?<name>pattern).
  • Character classes include [abc], [a-z], [0-9], and negated classes such as [^abc]. For Korean syllables, use the Unicode Hangul syllable range such as [\\uAC00-\\uD7A3].

Flags and examples

  • g global finds every match; i ignores case; m makes ^ and $ match each line; s lets . match newlines; u enables Unicode behavior; y sticky matches only at lastIndex.
  • A date pattern such as (\\d{4})-(\\d{2})-(\\d{2}) captures year, month, and day from 2026-03-03.
  • A masking pattern such as (\\d{6})-?([1-4])\\d{6} can replace a Korean resident number with $1-$2******.
  • For logs, \\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3} can find IPv4-like addresses.

Testing workflow and performance cautions

Tool behavior

  • Patterns are validated as they are typed, and invalid patterns are shown as errors.
  • Matched ranges are highlighted, and each match shows start and end indexes plus capture group details.
  • Replace mode previews text substitution using capture groups such as $1 and $2.
  • The explanation tab breaks complex patterns into token-level descriptions.

Avoid nested quantifiers such as (a+)+ when possible because they can cause catastrophic backtracking. Start with simple patterns, add conditions gradually, and test normal input, invalid input, empty strings, special characters, and newlines.