Tin mới
JavaScript: Scripting language
Web APIs: Programming interfaces
Structuring content with HTML module
Dynamic scripting with JavaScript module
The matchAll() method of String values returns an iterator of all results matching this string against a regular expression, including capturing groups.
An iterable iterator object (which is not restartable) of matches or an empty iterator if no matches are found. Each value yielded by the iterator is an array with the same shape as the return value of RegExp.prototype.e
An iterable iterator object (which is not restartable) of matches or an empty iterator if no matches are found. Each value yielded by the iterator is an array with the same shape as the return value of RegExp.prototype.e
RegExp.prototype[Symbol.matchAll]()
The implementation of String.prototype.matchAll doesn't do much other than calling the Symbol.matchAll method of the argument with the string as the first parameter (apart from the extra input validation that the regex i
Regexp.prototype.exec() and matchAll()
Without matchAll(), it's possible to use calls to regexp.exec() (and regexes with the g flag) in a loop to obtain all the matches:
Regexp.prototype.exec() and matchAll()
Without matchAll(), it's possible to use calls to regexp.exec() (and regexes with the g flag) in a loop to obtain all the matches:
Regexp.prototype.exec() and matchAll()
Without matchAll(), it's possible to use calls to regexp.exec() (and regexes with the g flag) in a loop to obtain all the matches:
Regexp.prototype.exec() and matchAll()
Without matchAll(), it's possible to use calls to regexp.exec() (and regexes with the g flag) in a loop to obtain all the matches:
Better access to capturing groups (than String.prototype.match())
Another compelling reason for matchAll is the improved access to capture groups.
This page was last modified on Jul 10, 2025 by MDN contributors.