From d44f5032d0f53256b2d5aef505d6b593fd3cd158 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:14:18 +0800 Subject: fix yari h2m dry run errors (zh-CN) --- .../global_objects/string/match/index.html | 71 ++-------------------- 1 file changed, 6 insertions(+), 65 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/string/match') 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 57bd74a182..48e537cb96 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 @@ -38,9 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match
  • input: 搜索的字符串.
  • -
    -
    一个{{jsxref("Array")}},其内容取决于global(g)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。
    -
    +

    一个{{jsxref("Array")}},其内容取决于global(g)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。

    描述

    @@ -60,7 +58,7 @@ 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 str = 'For more information, see Chapter 3.4.5.1';
     var re = /see (chapter \d+(\.\d)*)/i;
     var found = str.match(re);
     
    @@ -82,7 +80,7 @@ console.log(found);
     
     

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

    -
    var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    +
    var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
     var regexp = /[A-E]/gi;
     var matches_array = str.match(regexp);
     
    @@ -91,7 +89,7 @@ console.log(matches_array);
     
     

    使用match(),不传参数

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

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

    -
    var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.",
    +
    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"]
    @@ -145,64 +143,7 @@ str3.match(null);       // 返回["null"]

    浏览器兼容性

    -

    {{ 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() }}
    -
    - -

    Firefox 特殊注意

    - -
      -
    • 从Gecko 27 {{geckoRelease(27)}}开始,此方法遵守ECMAScript 规范。当使用全局正则表达式调用 match()时,{{jsxref("RegExp.lastIndex")}} 属性(如果指定)会重置为 0 ({{bug(501739)}})。
    • -
    • 从 Gecko 39 {{geckoRelease(39)}}开始,不赞成使用非标准的标志参数,并抛出一个控制台警告({{bug(1142351)}})。
    • -
    • 从 Gecko 47 {{geckoRelease(47)}} 开始 , non-release builds不再支持非标准的标志参数,并且将完全移除({{bug(1245801)}})。
    • -
    • 从 Gecko 49 {{geckoRelease(49)}} 开始 , 不再支持非标准的标志参数 ({{bug(1108382)}}).
    • -
    +{{Compat}}

    相关链接

    -- cgit v1.2.3-54-g00ecf