Regex Tester & Cheatsheet

Real-time pattern evaluation, match extraction, and regex syntax reference

//
3matches detected

Matched Results (3)

#1 (idx 47)alex.johnson@enterprise-cloud.io
#2 (idx 110)ndl.long.nguyendai@gmail.com
#3 (idx 175)support@ndlong.site

Essential Regular Expression Syntax Cheatsheet

Character Classes

  • . Any character except newline
  • \d Any digit [0-9]
  • \w Word char [a-zA-Z0-9_]
  • \s Whitespace character
  • [a-z] Character range a to z
  • [^0-9] Negated set (non-digits)

Quantifiers

  • * 0 or more occurrences
  • + 1 or more occurrences
  • ? 0 or 1 occurrence (optional)
  • {3} Exactly 3 times
  • {2,5} Between 2 and 5 times
  • +? Lazy quantifier

Anchors & Groups

  • ^ Start of string or line
  • $ End of string or line
  • \b Word boundary
  • (abc) Capturing group
  • (?:abc) Non-capturing group
  • a|b Alternation (a OR b)

Preventing ReDoS (Regular Expression Denial of Service)

Catastrophic backtracking occurs when nested quantifiers (such as `(a+)+$` or `([a-zA-Z]+)*`) encounter non-matching input strings. The regular expression engine enters exponential time complexity (`O(2^n)`), consuming 100% CPU on backend servers and causing entire Node.js, Python, or Go workers to freeze. Always audit regex patterns for ambiguous overlapping alternatives before production deployment.