Text Processingflags: g

Named Capture Group (Date)

Demonstrate named capture groups by extracting year/month/day from ISO-style dates.

Try it in RegexPro →

Available in

Pattern

regexengine-agnostic
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})   (flags: g)

Raw source: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})

How it works

(?<year>\d{4}) captures four digits under the name 'year'; (?<month>\d{2}) and (?<day>\d{2}) likewise. Modern JS, Python 3.7+, and Go (with `(?P<...>)` syntax — JS-style is also accepted in Python 3.12+) all support this; the matched substring is accessible by name in code (e.g. m.groups.year in JS, m['year'] in Python).

Examples

Input

Born 1990-05-21, hired 2018-09-10

Matches

  • 1990-05-21
  • 2018-09-10

Input

Today is 2026-04-25

Matches

  • 2026-04-25

Input

no dates here

No match

Common use cases

  • Self-documenting regex in production code
  • Extracting structured fields from log lines
  • Form field validation with named outputs
  • Building parsers without positional bookkeeping