mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-10 16:48:17 +08:00
124 lines
4.2 KiB
HTML
124 lines
4.2 KiB
HTML
<article id="wikiArticle">
|
||
<div></div>
|
||
<p><strong><code>flags</code></strong>属性返回一个字符串,由当前正则表达式对象的标志组成。</p>
|
||
<div><table class="standard-table">
|
||
<thead>
|
||
<tr>
|
||
<th class="header" colspan="2"><code>RegExp.prototype.flags</code> 属性的属性特性:</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>writable</td>
|
||
<td>false</td>
|
||
</tr>
|
||
<tr>
|
||
<td>enumerable</td>
|
||
<td>false</td>
|
||
</tr>
|
||
<tr>
|
||
<td>configurable</td>
|
||
<td>true</td>
|
||
</tr>
|
||
</tbody>
|
||
</table></div>
|
||
<h2 id="描述">描述</h2>
|
||
<p><code>flags</code>属性中的标志以字典序排序(从左到右,即<code>"gimuy"</code>)。</p>
|
||
<h2 id="示例">示例</h2>
|
||
<h3 id="使用flags">使用<code>flags</code></h3>
|
||
<pre><code class="language-javascript">/foo/ig.flags; // "gi"
|
||
/bar/myu.flags; // "muy"
|
||
</code></pre>
|
||
<h2 id="Polyfill">Polyfill</h2>
|
||
<pre><code class="language-javascript">if (RegExp.prototype.flags === undefined) {
|
||
Object.defineProperty(RegExp.prototype, 'flags', {
|
||
configurable: true,
|
||
get: function() {
|
||
return this.toString().match(/[gimuy]*$/)[0];
|
||
}
|
||
});
|
||
}
|
||
</code></pre>
|
||
<h2 id="规范">规范</h2>
|
||
<table class="standard-table">
|
||
<tbody>
|
||
<tr>
|
||
<th scope="col">Specification</th>
|
||
<th scope="col">Status</th>
|
||
<th scope="col">Comment</th>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">RegExp.prototype.flags</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td>初始定义。</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">RegExp.prototype.flags</small></a></td>
|
||
<td><span class="spec-Draft">Draft</span></td>
|
||
<td> </td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h2 id="浏览器兼容性">浏览器兼容性</h2>
|
||
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
|
||
This compatibility table still uses the old format,
|
||
because we haven't yet converted the data it contains.
|
||
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
|
||
<div class="htab">
|
||
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
|
||
<ul>
|
||
<li class="selected"><a>Desktop</a></li>
|
||
<li><a>Mobile</a></li>
|
||
</ul>
|
||
</div></div>
|
||
<div id="compat-desktop">
|
||
<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><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><a href="/en-US/Firefox/Releases/37" title="Released on 2015-04-07.">37</a> (37)</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="compat-mobile">
|
||
<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><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td>37.0 (37)</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<h2 id="另见">另见</h2>
|
||
<ul>
|
||
<li><a href="Reference/Global_Objects/RegExp/source" title="source 属性返回一个值为当前正则表达式对象的模式文本的字符串,该字符串不会包含正则字面量两边的斜杠以及任何的标志字符。"><code>RegExp.prototype.source</code></a></li>
|
||
</ul>
|
||
</article> |