Parentheses (…) capture a sub-match you can reference in the result or in a replacement ($1). Named groups (?<year>\d{4}) read out as match.groups.year — far clearer than numbered ones. Non-capturing groups (?:…) group without capturing.
Parentheses (…) capture a sub-match you can reference in the result or in a replacement ($1). Named groups (?<year>\d{4}) read out as match.groups.year — far clearer than numbered ones. Non-capturing groups (?:…) group without capturing.
<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const m='2026-05-28'.match(/(?<y>\d{4})-(?<mo>\d{2})-(?<d>\d{2})/);
document.getElementById('o').textContent=JSON.stringify(m.groups);</script></body></html>▶ Open the interactive comic issue