Symbol.matchAll
返回一个迭代器,该迭代器根据字符串生成正则表达式的匹配项。此函数可以被 String.prototype.matchAll()
方法调用。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
描述
此Symbol用于 RegExp.prototype[@@matchAll]()
。下面两个例子返回相同的结果:
'abc'.matchAll(/a/); /a/[Symbol.matchAll]('abc');
此方法用于自定义 RegExp
子类中的匹配行为。
Symbol.matchAll 属性的属性特性: |
|
---|---|
writable | false |
enumerable | false |
configurable | false |
示例
更多示例请查阅 RegExp.prototype[@@matchAll]()
。
规范
文档 | 状态 | 备注 |
---|---|---|
ECMAScript Latest Draft (ECMA-262) Symbol.matchAll |
Draft |
浏览器支持
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out
https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matchAll |
Chrome Full support 73 | Edge No support No | Firefox Full support 67 | IE No support No | Opera Full support 60 | Safari No support No | WebView Android Full support 73 | Chrome Android Full support 73 | Firefox Android Full support 67 | Opera Android Full support Yes | Safari iOS No support No | Samsung Internet Android No support No | nodejs Full support 12.0.0 |
Legend
- Full support
- Full support
- No support
- No support