Code Snippets

import re

text = "Date: 2026-05-12"
m = re.search(r"(?P<y>\d{4})-(?P<m>\d{2})-(?P<d>\d{2})", text)

if m:
    print(m.groupdict())