diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html new file mode 100644 index 0000000000..87b9ecb657 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html @@ -0,0 +1,99 @@ +--- +title: RegExp.input ($_) +slug: Web/JavaScript/Reference/Global_Objects/RegExp/input +translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/input +--- +<div>{{JSRef}} {{non-standard_header}}</div> + +<p><strong><code>input</code> </strong>非标准属性是正则表达式静态属性,含有正则表达式所匹配的字符串。<code>RegExp.$_</code>是这个属性的别名。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><var>RegExp</var>.input +RegExp.$_ +</pre> + +<h2 id="描述">描述</h2> + +<p><code>input</code> 属性是静态的,并不是正则表达式独立对象的属性。反之,你应始终将其使用为 <code>RegExp.input</code> 或者 <code>RegExp.$_。</code></p> + +<p>当正则表达式上搜索的字符串发生改变,并且字符串匹配时,<code><strong>input</strong></code> 属性的值会修改。</p> + +<h2 id="示例">示例</h2> + +<h3 id="使用_input_和__">使用 <code>input</code> 和 <code>$_</code></h3> + +<pre class="brush: js">var re = /hi/g; +re.test('hi there!'); +RegExp.input; // "hi there!" +re.test('foo'); // 新测试,不匹配 +RegExp.$_; // "hi there!" +re.test('hi world!'); // 新测试,匹配 +RegExp.$_; // "hi world!" +</pre> + +<h2 id="规范">规范</h2> + +<p>非标准。并不是任何现行规范的一部分。</p> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div>{{CompatibilityTable}}</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>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</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>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="另见">另见</h2> + +<ul> + <li>{{non-standard_inline}} {{jsxref("RegExp.lastMatch", "RegExp.lastMatch ($&)")}}</li> + <li>{{non-standard_inline}} {{jsxref("RegExp.lastParen", "RegExp.lastParen ($+)")}}</li> + <li>{{non-standard_inline}} {{jsxref("RegExp.leftContext", "RegExp.leftContext ($`)")}}</li> + <li>{{non-standard_inline}} {{jsxref("RegExp.rightContext", "RegExp.rightContext ($')")}}</li> + <li>{{non-standard_inline}} {{jsxref("RegExp.n", "RegExp.$1-$9")}}</li> +</ul> |