String.prototype.matchAllintermediateconst 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.
Each match result in matchAll is a full match object with capture groups at indices 1, 2, etc.
Challenge: Implement extractNumbers(str) that returns all digit sequences as numbers.
extractNumbers('price: 42 and 100') // β [42, 100]