Regex Tester

JavaScript-flavor regex. Matches highlight live as you type. Capture groups expand below.

Matches in context
Matches will appear here.
Try replace mode
After replacement
Replaced output appears here.
Regex cheat sheet

Anchors & boundaries

  • ^ start of string (or line, with m flag)
  • $ end of string (or line, with m flag)
  • \b word boundary

Character classes

  • \d digit, \D non-digit
  • \w word char ([A-Za-z0-9_]), \W non-word
  • \s whitespace, \S non-whitespace
  • [abc] any of a/b/c, [^abc] none of
  • . any char (except newline unless s flag)

Quantifiers

  • * 0+, + 1+, ? 0 or 1
  • {3} exactly 3, {3,5} 3 to 5, {3,} 3 or more
  • Add ? for lazy: *?, +?, ??

Groups

  • (abc) capturing group β€” referenced by $1, $2, …
  • (?:abc) non-capturing
  • (?<name>abc) named capture, referenced as $<name>
  • (?=abc) lookahead, (?!abc) negative lookahead
  • (?<=abc) lookbehind, (?<!abc) negative lookbehind

Flags

  • g global (find all matches, not just first)
  • i case-insensitive
  • m multiline (^ and $ match line boundaries)
  • s dotall (. matches newlines too)
  • u Unicode
  • y sticky