JS Built-ins
StringString.prototype.matchAlladvanced

String.prototype.matchAll() β€” named capture groups

πŸ“– Usage Example
const str = 'a1 b2 c3'
const matches = [...str.matchAll(/(w)(d)/g)]
matches.length   // β†’ 3
matches[0][1]    // β†’ 'a'

Use matchAll() with the g flag to iterate over all regex matches and access capture groups in each result.

String.prototype.matchAll() β€” Named Groups

Named groups from each match are in match.groups.

Challenge: Implement extractKeyValues(str) that parses key=value pairs from a string.

extractKeyValues('a=1 b=2 c=3') // β†’ [{ key: 'a', value: '1' }, ...]
πŸ’‘ Hints (1)
  • β€’ Access named groups via `m.groups!.key` and `m.groups!.value`.