Skip to main content

JavaScript Regex Explainer

Explain JavaScript regular-expression syntax as a nested, token-level breakdown without running patterns. Parsing stays in your browser; input is limited to 500 UTF-16 code units.

Patterns are parsed locally and never run. Parsing follows the latest ECMAScript grammar supported by the parser; older browsers may support different syntax. Limits: 500 UTF-16 code units and 8 flags.

Explanation

  • ^Start-of-line assertion.
  • (?<year>\d{4})Named capturing group "year".
    • \d{4}Repeat the preceding expression exactly 4 times (greedy).
      • \dA digit.
  • -Literal character "-".
  • (\d{2})Capturing group; stores the matched text.
    • \d{2}Repeat the preceding expression exactly 2 times (greedy).
      • \dA digit.
  • -Literal character "-".
  • (\d{2})Capturing group; stores the matched text.
    • \d{2}Repeat the preceding expression exactly 2 times (greedy).
      • \dA digit.
  • $End-of-line assertion.

Flags

  • mTreat ^ and $ as line boundaries.

Was this tool helpful?