非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

The non-standard input property is a static property of regular expressions that contains the string against which a regular expression is matched. RegExp.$_ is an alias for this property.

描述

input property is static, it is not a property of an individual regular expression object. Instead, you always use it as RegExp.input or RegExp.$_.

The value of the input property is modified whenever the searched string on the regular expression is changed and that string is matching.

范例

使用 input and $_

var re = /hi/g;
re.test('hi there!');
RegExp.input;         // "hi there!"
re.test('foo');       // new test, non-matching
RegExp.$_;            // "hi there!"
re.test('hi world!'); // new test, matching
RegExp.$_;            // "hi world!"
					

规范

规范
Legacy RegExp features in JavaScript

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
RegExp.input ( $_ ) 非标 Chrome 1 Edge 12 Firefox 1 IE 5.5 Opera 15 Safari 3 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 14 Safari iOS 1 Samsung Internet Android 1.0 nodejs Yes

图例

完整支持

完整支持

非标。预期跨浏览器支持较差。

另请参阅

元数据

  • 最后修改: