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/rightcontext/index.html | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext') diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html new file mode 100644 index 0000000000..5426301369 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html @@ -0,0 +1,98 @@ +--- +title: RegExp.rightContext ($') +slug: Web/JavaScript/Reference/Global_Objects/RegExp/rightContext +translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/rightContext +--- +
{{JSRef}} {{non-standard_header}}
+ +

rightContext 非标准属性是正则表达式的静态和只读属性,含有最新匹配的右侧子串。 RegExp.$' 是这个属性的别名。

+ +

语法

+ +
RegExp.rightContext
+RegExp["$'"]
+
+ +

描述

+ +

rightContext 属性是静态的,不是正则表达式独立对象的属性。反之,你应始终将其使用为 RegExp.rightContext 或者 RegExp["$'"]

+ +

rightContext 属性的值是只读的,并且会在匹配成功时修改。

+ +

你不能使用属性访问器(RegExp.$')来使用简写的别名,因为解析器在这里会将其看做字符串的开始,并抛出 {{jsxref("SyntaxError")}}。使用 方括号符号来访问属性。

+ +

示例

+ +

使用 rightContext$'

+ +
var re = /hello/g;
+re.test('hello world!');
+RegExp.rightContext; // " world!"
+RegExp["$'"];       // " world!"
+
+ +

规范

+ +

非标准。并不是任何现行规范的一部分。

+ +

浏览器兼容性

+ +
{{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