aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/symbol/matchall/index.html
blob: 730107b31c4bb109293ee2e7d59988ac43d83594 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: Symbol.matchAll
slug: Web/JavaScript/Reference/Global_Objects/Symbol/matchAll
tags:
  - JavaScript
  - Property
  - Reference
  - Symbol
translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/matchAll
---
<div>{{JSRef}}</div>

<p><code><strong>Symbol.matchAll</strong></code> 返回一个迭代器,该迭代器根据字符串生成正则表达式的匹配项。此函数可以被 {{jsxref("String.prototype.matchAll()")}} 方法调用。</p>

<div>{{EmbedInteractiveExample("pages/js/symbol-matchall.html")}}</div>



<h2 id="描述">描述</h2>

<div>
<p>此Symbol用于 {{jsxref("String.prototype.matchAll()")}} 特别是 {{jsxref("RegExp.@@matchAll", "RegExp.prototype[@@matchAll]()")}}。下面两个例子返回相同的结果:</p>

<pre class="brush: js">'abc'.matchAll(/a/);

/a/[Symbol.matchAll]('abc');</pre>

<p>此方法用于自定义 {{jsxref("RegExp")}} 子类中的匹配行为。</p>

<p>{{js_property_attributes(0,0,0)}}</p>
</div>

<h2 id="示例">示例</h2>

<p>更多示例请查阅 {{jsxref("String.prototype.matchAll()")}}{{jsxref("RegExp.@@matchAll", "RegExp.prototype[@@matchAll]()")}}</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">文档</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-symbol.matchall', 'Symbol.matchAll')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器支持">浏览器支持</h2>



<p>{{Compat("javascript.builtins.Symbol.matchAll")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{jsxref("String.prototype.matchAll()")}}</li>
 <li>{{jsxref("RegExp.@@matchAll", "RegExp.prototype[@@matchAll]()")}}</li>
</ul>