String.prototype.matchAll

Matches a string and returns an iterable of matches containing the results of the match.

Syntax

matchAll(value)

Parameters

Return value

An iterable of matches containing the results of the match.

Examples

for (const match of "banana".matchAll(/an/g)) {
  print(match[0], match.index, match.input, match.groups)
}
an 1 banana undefined
an 3 banana undefined