Regex Tester

Pattern
JavaScript pattern only (no surrounding slashes). Updates in real time.
Text
Matches below will highlight instantly as you type.
Options
Flag: g
Global search — find all matches, not just the first.
Flag: i
Ignore case — case-insensitive matching (A = a).
Flag: m
Multiline — ^ and $ match line starts/ends, not just the whole string.
Flag: s
DotAll — make . match newline characters as well.
Flag: u
Unicode — enable full Unicode mode; recommended for modern text.
Flag: y
Sticky — match must start exactly at lastIndex (useful for incremental scans).
Flag: d
Indices — expose start/end indices for the full match and capture groups (browser-dependent).

About the Regex Tester

Live-test JavaScript regular expressions in your browser. As you type, matches are highlighted below and a detailed text report is generated for copying or sharing.

Quick Regex Guide

  • Literals & escaping: most characters match themselves. Use backslash to escape (e.g. \. for a literal dot).
  • Common classes: \d digits, \w word chars, \s whitespace. Uppercase negates: \D, \W, \S.
  • Anchors: ^ start, $ end; with m they apply per line.
  • Quantifiers: a* 0+, a+ 1+, a? 0/1, a{2,5} range. Add ? to make non-greedy: +?, *?.
  • Groups: (...) capture; (?:...) non-capture; named capture (?<name>...).
  • Alternation: a|b matches either side.
  • Lookarounds: (?=...) ahead, (?!...) neg-ahead, (?<=...) behind, (?<!...) neg-behind.
  • Flags: g all matches, i ignore case, m multiline, s dotAll, u Unicode, y sticky, d indices.

Examples

  • Email (simple): \b(\w+)@([\w.-]+)\.(\w+)\b
  • ISO date: \b(\d{4})-(\d{2})-(\d{2})\b
  • Price: \$\d+(?:\.\d{2})?

Tips

  • Prefer u flag for modern text handling.
  • Use non-capturing groups (?: ) when you don’t need captured values.
  • Beware of catastrophic backtracking with nested, ambiguous quantifiers.