diff options
author | Irvin <irvinfly@gmail.com> | 2022-02-16 02:14:18 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | d44f5032d0f53256b2d5aef505d6b593fd3cd158 (patch) | |
tree | 4b585f4be9c9a2712664ad10e7acf62c83fff51f /files/zh-cn/web/javascript/reference/global_objects/string/match | |
parent | f45e9e070c93ebbd83d488bdd775987a4d75c201 (diff) | |
download | translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.gz translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.bz2 translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.zip |
fix yari h2m dry run errors (zh-CN)
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/string/match')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/string/match/index.html | 71 |
1 files changed, 6 insertions, 65 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html index 57bd74a182..48e537cb96 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html @@ -38,9 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match <li><code>input</code>: 搜索的字符串.</li> </ul> -<dl> - <dd>一个{{jsxref("Array")}},其内容取决于global(<code>g</code>)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。</dd> -</dl> +<p>一个{{jsxref("Array")}},其内容取决于global(<code>g</code>)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。</p> <h2 id="Description">描述</h2> @@ -60,7 +58,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match <p>在下例中,使用 <code>match</code> 查找 "<code>Chapter</code>" 紧跟着 1 个或多个数值字符,再紧跟着一个小数点和数值字符 0 次或多次。正则表达式包含 <code>i</code> 标志,因此大小写会被忽略。</p> -<pre class="brush: js line-numbers language-js">var str = 'For more information, see Chapter 3.4.5.1'; +<pre class="brush: js">var str = 'For more information, see Chapter 3.4.5.1'; var re = /see (chapter \d+(\.\d)*)/i; var found = str.match(re); @@ -82,7 +80,7 @@ console.log(found); <p>下例展示了 <code>match</code> 使用 global 和 ignore case 标志。A-E、a-e 的所有字母将会作为一个数组的元素返回。</p> -<pre class="brush: js line-numbers language-js">var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; +<pre class="brush: js">var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; var regexp = /[A-E]/gi; var matches_array = str.match(regexp); @@ -91,7 +89,7 @@ console.log(matches_array); <h3 id="使用match,不传参数"><code>使用match(),不传参数 </code></h3> -<pre class="brush: js line-numbers language-js">var str = "Nothing will come of nothing."; +<pre class="brush: js">var str = "Nothing will come of nothing."; str.match(); // returns [""]</pre> @@ -99,7 +97,7 @@ str.match(); // returns [""]</pre> <p>当参数是一个字符串或一个数字,它会使用new RegExp(obj)来隐式转换成一个 {{jsxref("RegExp")}}。如果它是一个有正号的正数,RegExp() 方法将忽略正号。</p> -<pre class="brush: js line-numbers language-js">var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.", +<pre class="brush: js">var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.", str2 = "My grandfather is 65 years old and My grandmother is 63 years old.", str3 = "The contract was declared null and void."; str1.match("number"); // "number" 是字符串。返回["number"] @@ -145,64 +143,7 @@ str3.match(null); // 返回["null"]</pre> <h2 id="浏览器兼容性">浏览器兼容性</h2> -<p>{{ CompatibilityTable() }}</p> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="Firefox_特殊注意">Firefox 特殊注意</h2> - -<ul> - <li>从Gecko 27 {{geckoRelease(27)}}开始,此方法遵守ECMAScript 规范。当使用全局正则表达式调用 <code>match()时,</code>{{jsxref("RegExp.lastIndex")}} 属性(如果指定)会重置为 <code>0</code> ({{bug(501739)}})。</li> - <li>从 Gecko 39 {{geckoRelease(39)}}开始,不赞成使用非标准的标志参数,并抛出一个控制台警告({{bug(1142351)}})。</li> - <li>从 Gecko 47 {{geckoRelease(47)}} 开始 , non-release builds不再支持非标准的标志参数,并且将完全移除({{bug(1245801)}})。</li> - <li>从 Gecko 49 {{geckoRelease(49)}} 开始 , 不再支持非标准的标志参数 ({{bug(1108382)}}).</li> -</ul> +{{Compat}} <h2 id="See_also">相关链接</h2> |