From 012ee621791b6895e637f96e6523027951768f25 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:03:27 +0800 Subject: remove inline style for zh-CN --- .../global_objects/regexp/lastindex/index.html | 57 ++++++++++------------ 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex') diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html index f7e667288f..92dadc8159 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html @@ -10,41 +10,34 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex ---
{{JSRef("Global_Objects", "RegExp")}}
-

概述

+

概述

lastIndex 是正则表达式的一个可读可写的整型属性,用来指定下一次匹配的起始索引。

{{js_property_attributes(1,0,0)}}
-

语法

-
lastIndex = regExpObj.lastIndex;
-

描述

+

语法

+
lastIndex = regExpObj.lastIndex;
+

描述

只有正则表达式使用了表示全局检索的 "g" 标志时,该属性才会起作用。此时应用下面的规则:

-

示例

+

示例

考虑下面的语句:

var re = /(hi)?/g;
-
-  
+

匹配空字符串

console.log(re.exec("hi"));
 console.log(re.lastIndex);
-
-  
-
-  
+

返回 ["hi", "hi"] ,lastIndex 等于 2。

console.log(re.exec("hi"));
 console.log(re.lastIndex);
-
-  
-
-  
+

返回 ["", undefined],即一个数组,其第 0 个元素为匹配的字符串。此种情况下为空字符串,是因为 lastIndex 为 2(且一直是 2),"hi" 长度为 2。

-

规范

+

规范

@@ -70,18 +63,18 @@ console.log(re.lastIndex);
-

浏览器兼容性

+

浏览器兼容性

{{ CompatibilityTable() }}

- - - - - - + + + + + + @@ -98,13 +91,13 @@ console.log(re.lastIndex);
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafariFeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support
- - - - - - - + + + + + + + @@ -118,7 +111,7 @@ console.log(re.lastIndex);
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileFeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support
-

相关链接

+

相关链接