From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/regexp/tostring/index.html | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/regexp/tostring') diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html new file mode 100644 index 0000000000..22aef815b4 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html @@ -0,0 +1,106 @@ +--- +title: RegExp.prototype.toString() +slug: Web/JavaScript/Reference/Global_Objects/RegExp/toString +tags: + - JavaScript + - Method + - Prototype + - RegExp +translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/toString +--- +
+ {{JSRef("Global_Objects", "RegExp")}}
+

概述

+

toString() 返回一个表示该正则表达式的字符串。

+

语法

+
regexObj.toString()
+

参数

+

+

描述

+

{{jsxref("Global_Objects/RegExp", "RegExp")}} 对象覆盖了 {{jsxref("Global_Objects/Object", "Object")}} 对象的 toString() 方法,并没有继承 {{jsxref("Object.prototype.toString()")}}。对于 RegExp 对象,toString 方法返回一个该正则表达式的字符串形式。

+

示例

+

例子:使用 toString

+

下例输出 RegExp 对象的字符串值:

+
myExp = new RegExp("a+b+c");
+alert(myExp.toString());       // 显示 "/a+b+c/"
+
+foo = new RegExp("bar", "g");
+alert(foo.toString());         // 显示 "/bar/g"
+
+

规范

+ + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
ECMAScript 3rd Edition. Implemented in JavaScript 1.1StandardInitial definition.
{{SpecName('ES5.1', '#sec-15.9.5.2', 'RegExp.prototype.toString')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-regexp.prototype.tostring', 'RegExp.prototype.toString')}}{{Spec2('ES6')}} 
+

浏览器兼容性

+

{{ CompatibilityTable() }}

+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+

相关链接

+ -- cgit v1.2.3-54-g00ecf