Regex Syntax

A reference for the core regular-expression syntax: classes, quantifiers, anchors, and groups.

A regular expression is a small language for describing text patterns. The core building blocks are character classes, quantifiers, anchors, and groups.

01Core building blocks

  • Character classes: [abc], [^abc], and shorthand such as \d and \w.
  • Quantifiers: *, +, ?, and {m,n}, greedy or lazy.
  • Anchors: ^ and $, with multiline behavior controlled by flags.
  • Groups: capturing ( ) and non-capturing (?: ).

02Limitations

This is not a complete ECMAScript specification and omits engine-specific extensions.

Sources

  1. MDN: Regular expressions — MDN Web Docs (accessed 2026-09-01)