From d9e9adb5f80a819fe46349bcf6d1faec734b09cd Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:07:31 +0800 Subject: remove span tag in zh-CN --- .../global_objects/string/fixed/index.html | 2 +- .../reference/global_objects/string/index.html | 4 +- .../global_objects/string/lastindexof/index.html | 2 +- .../global_objects/string/localecompare/index.html | 2 +- .../global_objects/string/match/index.html | 68 +++++++-------- .../global_objects/string/normalize/index.html | 2 +- .../global_objects/string/repeat/index.html | 96 +++++++++++----------- .../global_objects/string/replace/index.html | 2 +- .../global_objects/string/replaceall/index.html | 2 +- .../global_objects/string/slice/index.html | 2 +- .../global_objects/string/startswith/index.html | 2 +- .../global_objects/string/substr/index.html | 2 +- .../global_objects/string/substring/index.html | 2 +- .../global_objects/string/tolowercase/index.html | 2 +- 14 files changed, 95 insertions(+), 95 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/string') diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html index f4af9c1103..03576dd5a1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html @@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fixed

描述

-

fixed() 方法将一个字符串包裹在<tt></tt>标签中,比如: "<tt>str</tt>".

+

fixed() 方法将一个字符串包裹在<tt></tt>标签中,比如: "<tt>str</tt>".

举例

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/index.html index d8b23c0904..5cea932350 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/index.html @@ -245,7 +245,7 @@ console.log(String.replace(num, /5/, '2'));

移除字符串泛型的措施,参见 Warning: String.x is deprecated; use String.prototype.x instead.

-

{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}} 在 Javascript 1.6 中同样支持{{jsxref("Global_Objects/Array", "Array")}}。

+

{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}} 在 Javascript 1.6 中同样支持{{jsxref("Global_Objects/Array", "Array")}}。

String 实例

@@ -253,7 +253,7 @@ console.log(String.replace(num, /5/, '2'));

{{page('zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'Properties')}}

-

{{page('zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'Methods')}}

+

{{page('zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'Methods')}}

示例 

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html index 3c3e51d666..e4b6dd8681 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html @@ -3,7 +3,7 @@ title: String.prototype.lastIndexOf() slug: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf --- -

{{JSRef}}

+

 {{JSRef}}

 lastIndexOf() 方法返回调用{{jsxref("String")}} 对象的指定值最后一次出现的索引,在一个字符串中的指定位置 fromIndex处从后向前搜索。如果没找到这个特定值则返回-1 。

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/localecompare/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/localecompare/index.html index 9a55c1bb88..e7948450a1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/localecompare/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/localecompare/index.html @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/localeCompare
compareString
用来比较的字符串
-
locales
+
locales
可选。 用来表示一种或多种语言或区域的一个符合 BCP 47 标准的字符串或一个字符串数组。 locales参数的一般形式与解释, 详情请参考 Intl page。 下列的 Unicode 扩展关键词是允许的:
co
为了某些地域多样的排序规则。可能的值包括: "big5han""dict""direct""ducet""gb2312""phonebk""phonetic""pinyin""reformed""searchjl""stroke""trad""unihan"。 "standard" 和"search" 这两个值是被忽略的; 它们被 options 的属性 usage 代替(往下看)。
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html index 9922ea3291..cc979f7ffe 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html @@ -26,8 +26,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match

返回值

附加属性

@@ -62,56 +62,56 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match

在下例中,使用 match 查找 "Chapter" 紧跟着 1 个或多个数值字符,再紧跟着一个小数点和数值字符 0 次或多次。正则表达式包含 i 标志,因此大小写会被忽略。

-
var str = 'For more information, see Chapter 3.4.5.1';
-var re = /see (chapter \d+(\.\d)*)/i;
-var found = str.match(re);
+
var str = 'For more information, see Chapter 3.4.5.1';
+var re = /see (chapter \d+(\.\d)*)/i;
+var found = str.match(re);
 
-console.log(found);
+console.log(found);
 
-// logs [ 'see Chapter 3.4.5.1',
-//        'Chapter 3.4.5.1',
-//        '.1',
-//        index: 22,
-//        input: 'For more information, see Chapter 3.4.5.1' ]
+// logs [ 'see Chapter 3.4.5.1',
+//        'Chapter 3.4.5.1',
+//        '.1',
+//        index: 22,
+//        input: 'For more information, see Chapter 3.4.5.1' ]
 
-// 'see Chapter 3.4.5.1' 是整个匹配。
-// 'Chapter 3.4.5.1' 被'(chapter \d+(\.\d)*)'捕获。
-// '.1' 是被'(\.\d)'捕获的最后一个值。
-// 'index' 属性(22) 是整个匹配从零开始的索引。
-// 'input' 属性是被解析的原始字符串。
+// 'see Chapter 3.4.5.1' 是整个匹配。 +// 'Chapter 3.4.5.1' 被'(chapter \d+(\.\d)*)'捕获。 +// '.1' 是被'(\.\d)'捕获的最后一个值。 +// 'index' 属性(22) 是整个匹配从零开始的索引。 +// 'input' 属性是被解析的原始字符串。

例子:match 使用全局(global)和忽略大小写(ignore case)标志

下例展示了 match 使用 global 和 ignore case 标志。A-E、a-e 的所有字母将会作为一个数组的元素返回。

-
var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
-var regexp = /[A-E]/gi;
-var matches_array = str.match(regexp);
+
var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
+var regexp = /[A-E]/gi;
+var matches_array = str.match(regexp);
 
-console.log(matches_array);
-// ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']
+console.log(matches_array); +// ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']

使用match(),不传参数

-
var str = "Nothing will come of nothing.";
+
var str = "Nothing will come of nothing.";
 
-str.match();   // returns [""]
+str.match(); // returns [""]

一个非正则表达式对象作为参数

当参数是一个字符串或一个数字,它会使用new RegExp(obj)来隐式转换成一个 {{jsxref("RegExp")}}。如果它是一个有正号的正数,RegExp() 方法将忽略正号。

-
var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.",
-    str2 = "My grandfather is 65 years old and My grandmother is 63 years old.",
-    str3 = "The contract was declared null and void.";
-str1.match("number");   // "number" 是字符串。返回["number"]
-str1.match(NaN);        // NaN的类型是number。返回["NaN"]
-str1.match(Infinity);   // Infinity的类型是number。返回["Infinity"]
-str1.match(+Infinity);  // 返回["Infinity"]
-str1.match(-Infinity);  // 返回["-Infinity"]
-str2.match(65);         // 返回["65"]
-str2.match(+65);        // 有正号的number。返回["65"]
-str3.match(null);       // 返回["null"]
+
var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.",
+    str2 = "My grandfather is 65 years old and My grandmother is 63 years old.",
+    str3 = "The contract was declared null and void.";
+str1.match("number");   // "number" 是字符串。返回["number"]
+str1.match(NaN);        // NaN的类型是number。返回["NaN"]
+str1.match(Infinity);   // Infinity的类型是number。返回["Infinity"]
+str1.match(+Infinity);  // 返回["Infinity"]
+str1.match(-Infinity);  // 返回["-Infinity"]
+str2.match(65);         // 返回["65"]
+str2.match(+65);        // 有正号的number。返回["65"]
+str3.match(null);       // 返回["null"]

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/normalize/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/normalize/index.html index d88c6826a0..f14e1d4a36 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/normalize/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/normalize/index.html @@ -54,7 +54,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/normalize
{{jsxref("RangeError")}}
-
如果给 form 传入了上述四个字符串以外的参数,则会抛出 RangeError 异常。
+
如果给 form 传入了上述四个字符串以外的参数,则会抛出 RangeError 异常。

描述

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html index ce35065f1a..b880c16b92 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html @@ -44,59 +44,59 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat

此方法已添加到 ECMAScript 2015 规范中,并且可能尚未在所有 JavaScript 实现中可用。然而,你可以使用以下代码段对 String.prototype.repeat() 进行填充:

-
if (!String.prototype.repeat) {
-  String.prototype.repeat = function(count) {
-    'use strict';
-    if (this == null) {
-      throw new TypeError('can\'t convert ' + this + ' to object');
-    }
-    var str = '' + this;
-    count = +count;
-    if (count != count) {
-      count = 0;
-    }
-    if (count < 0) {
-      throw new RangeError('repeat count must be non-negative');
-    }
-    if (count == Infinity) {
-      throw new RangeError('repeat count must be less than infinity');
-    }
-    count = Math.floor(count);
-    if (str.length == 0 || count == 0) {
-      return '';
-    }
-    // 确保 count 是一个 31 位的整数。这样我们就可以使用如下优化的算法。
-    // 当前(2014年8月),绝大多数浏览器都不能支持 1 << 28 长的字符串,所以:
-    if (str.length * count >= 1 << 28) {
-      throw new RangeError('repeat count must not overflow maximum string size');
-    }
-    var rpt = '';
-    for (;;) {
-      if ((count & 1) == 1) {
-        rpt += str;
-      }
-      count >>>= 1;
-      if (count == 0) {
-        break;
-      }
-      str += str;
-    }
-    return rpt;
-  }
-}
+
if (!String.prototype.repeat) {
+  String.prototype.repeat = function(count) {
+    'use strict';
+    if (this == null) {
+      throw new TypeError('can\'t convert ' + this + ' to object');
+    }
+    var str = '' + this;
+    count = +count;
+    if (count != count) {
+      count = 0;
+    }
+    if (count < 0) {
+      throw new RangeError('repeat count must be non-negative');
+    }
+    if (count == Infinity) {
+      throw new RangeError('repeat count must be less than infinity');
+    }
+    count = Math.floor(count);
+    if (str.length == 0 || count == 0) {
+      return '';
+    }
+    // 确保 count 是一个 31 位的整数。这样我们就可以使用如下优化的算法。
+    // 当前(2014年8月),绝大多数浏览器都不能支持 1 << 28 长的字符串,所以:
+    if (str.length * count >= 1 << 28) {
+      throw new RangeError('repeat count must not overflow maximum string size');
+    }
+    var rpt = '';
+    for (;;) {
+      if ((count & 1) == 1) {
+        rpt += str;
+      }
+      count >>>= 1;
+      if (count == 0) {
+        break;
+      }
+      str += str;
+    }
+    return rpt;
+  }
+}

示例

-
"abc".repeat(-1)     // RangeError: repeat count must be positive and less than inifinity
-"abc".repeat(0)      // ""
-"abc".repeat(1)      // "abc"
-"abc".repeat(2)      // "abcabc"
-"abc".repeat(3.5)    // "abcabcabc" 参数count将会被自动转换成整数.
-"abc".repeat(1/0)    // RangeError: repeat count must be positive and less than inifinity
+
"abc".repeat(-1)     // RangeError: repeat count must be positive and less than inifinity
+"abc".repeat(0)      // ""
+"abc".repeat(1)      // "abc"
+"abc".repeat(2)      // "abcabc"
+"abc".repeat(3.5)    // "abcabcabc" 参数count将会被自动转换成整数.
+"abc".repeat(1/0)    // RangeError: repeat count must be positive and less than inifinity
 
-({toString : () => "abc", repeat : String.prototype.repeat}).repeat(2)
-//"abcabc",repeat是一个通用方法,也就是它的调用者可以不是一个字符串对象.
+({toString : () => "abc", repeat : String.prototype.repeat}).repeat(2) +//"abcabc",repeat是一个通用方法,也就是它的调用者可以不是一个字符串对象.

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html index 45421c8b54..49f27efe4b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html @@ -193,7 +193,7 @@ console.log(newstr); } -

运行 styleHyphenFormat('borderTop')返回 'border-top'。

+

运行 styleHyphenFormat('borderTop')将返回 'border-top'。

因为我们想在最终的替换中进一步转变匹配结果,所以我们必须使用一个函数。这迫使我们在使用{{jsxref("String.prototype.toLowerCase()", "toLowerCase()")}}方法前进行评估。如果我们尝试不用一个函数进行匹配,那么使用{{jsxref("String.prototype.toLowerCase()", "toLowerCase()")}} 方法将不会有效。

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html index 69c92e87dc..cbd76d71b7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html @@ -9,7 +9,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replaceAll ---
{{JSRef}}
-

replaceAll() 方法返回一个新字符串,新字符串所有满足 pattern 的部分都已被replacement 替换。pattern可以是一个字符串或一个 {{jsxref("RegExp")}}, replacement可以是一个字符串或一个在每次匹配被调用的函数。

+

replaceAll() 方法返回一个新字符串,新字符串所有满足 pattern 的部分都已被replacement 替换。pattern可以是一个字符串或一个 {{jsxref("RegExp")}}, replacement可以是一个字符串或一个在每次匹配被调用的函数。

原始字符串保持不变。

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html index df8f398983..35f5dd5736 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/slice
beginIndex
从该索引(以 0 为基数)处开始提取原字符串中的字符。如果值为负数,会被当做 strLength + beginIndex 看待,这里的strLength 是字符串的长度(例如, 如果 beginIndex 是 -3 则看作是:strLength - 3
endIndex
-
可选。在该索引(以 0 为基数)处结束提取字符串。如果省略该参数,slice() 会一直提取到字符串末尾。如果该参数为负数,则被看作是 strLength + endIndex,这里的 strLength 就是字符串的长度(例如,如果 endIndex 是 -3,则是, strLength - 3)。
+
可选。在该索引(以 0 为基数)处结束提取字符串。如果省略该参数,slice() 会一直提取到字符串末尾。如果该参数为负数,则被看作是 strLength + endIndex,这里的 strLength 就是字符串的长度(例如,如果 endIndex 是 -3,则是, strLength - 3)。

返回值

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/startswith/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/startswith/index.html index 747878e5b9..7cbd48ba7b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/startswith/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/startswith/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/startsWith ---
{{JSRef}}
-

startsWith() 方法用来判断当前字符串是否以另外一个给定的子字符串开头,并根据判断结果返回 truefalse

+

startsWith() 方法用来判断当前字符串是否以另外一个给定的子字符串开头,并根据判断结果返回 truefalse

{{EmbedInteractiveExample("pages/js/string-startswith.html")}}
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html index 8faa458218..782816ee91 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substr
start
-
开始提取字符的位置。如果为负值,则被看作 strLength + start,其中 strLength 为字符串的长度(例如,如果 start-3,则被看作 strLength + (-3))。
+
开始提取字符的位置。如果为负值,则被看作 strLength + start,其中 strLength 为字符串的长度(例如,如果 start-3,则被看作 strLength + (-3))。
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html index 9a2d97f935..e2b061d1a3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html @@ -105,7 +105,7 @@ replaceString("World", "Web", "Brave New World"); return fullS.split(oldS).join(newS); } -

上面的代码只是子字符串操作的一个例子。如果你需要替换子字符串,更多时候会用到 {{jsxref("String.prototype.replace()")}}。

+

上面的代码只是子字符串操作的一个例子。如果你需要替换子字符串,更多时候会用到 {{jsxref("String.prototype.replace()")}}。

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html index e08a47bb55..b0ecb92a51 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toLowerCase
-

说明

+

说明

-- cgit v1.2.3-54-g00ecf