Bu Endang's loan cards: a date read with (?<tahun>…), then written again through $<tahun>. m.groups and replace from the real JS engine. An interactive Regex…
Why it matters
Reading dates, logs, URLs and codes is daily work. A pattern read through m[3] is fragile: one change of order, and wrong values flow on silently. Names make a regex explain itself and survive edits.
The key idea
A name gives every group a stable key; a number follows position
Try it in this playground
Switch to numbered groupsm.groups becomes undefined; every part only has its position number.
Turn the order round with named groups Pick the 16/06/2026 card: the numbers shift, but the named replacement still gives ISO.
Rename a group Say tahun to year: m.groups.year is there at once.
Give two groups the same name The engine refuses it with a SyntaxError.