语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -2,7 +2,7 @@
<div></div>
<p><em>正则表达式</em>匹配<em>字符串</em>时,<strong><code>[@@match]()</code></strong>方法用于获取匹配结果。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"><var>regexp</var>[Symbol.match](str)</pre>
<pre><code class="language-javascript"><var>regexp</var>[Symbol.match](str)</code></pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>str</code></dt>
@@ -12,21 +12,21 @@
<p>match 方法会返回一个数组它包括整个匹配结果和通过捕获组匹配到的结果如果没有匹配到则返回null</p>
<h2 id="描述">描述</h2>
<p>这个方法在 <a href="Reference/Global_Objects/String/match" title="当一个字符串与一个正则表达式匹配时 match()方法检索匹配项。"><code>String.prototype.match()</code></a> 的内部调用。例如,下面的两个方法返回相同结果。</p>
<pre class="brush: js">'abc'.match(/a/);
<pre><code class="language-javascript">'abc'.match(/a/);
/a/[Symbol.match]('abc');</pre>
/a/[Symbol.match]('abc');</code></pre>
<p>这个方法为自定义 <code>RegExp</code> 子类中的匹配行为而存在。</p>
<h2 id="示例">示例</h2>
<h3 id="直接调用">直接调用</h3>
<p>这个方法的使用方式和 <a href="Reference/Global_Objects/String/match" title="当一个字符串与一个正则表达式匹配时 match()方法检索匹配项。"><code>String.prototype.match()</code></a> 相同,不同之处是 <code>this</code> 和参数顺序。</p>
<pre class="brush: js">var re = /[0-9]+/g;
<pre><code class="language-javascript">var re = /[0-9]+/g;
var str = '2016-01-02';
var result = re[Symbol.match](str);
console.log(result); // ["2016", "01", "02"]
</pre>
</code></pre>
<h3 id="在子类中使用match">在子类中使用<code>@@match</code></h3>
<p><a href="Reference/RegExp" title="此页面仍未被本地化, 期待您的翻译!"><code>RegExp</code></a> 的子类可以覆写 <code>[@@match]()</code>方法来修改默认行为。</p>
<pre class="brush: js">class MyRegExp extends RegExp {
<pre><code class="language-javascript">class MyRegExp extends RegExp {
[Symbol.match](str) {
var result = RegExp.prototype[Symbol.match].call(this, str);
if (!result) return null;
@@ -44,7 +44,7 @@ var result = str.match(re); // String.prototype.match calls re[@@match].
console.log(result.group(1)); // 2016
console.log(result.group(2)); // 01
console.log(result.group(3)); // 02
</pre>
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>