From 01b0e12ba27b5069248fd09235e9a7143915ee30 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:02:49 +0800 Subject: remove `notranslate` class in zh-CN --- .../reference/global_objects/string/replaceall/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/string/replaceall') 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 cbd76d71b7..c9d892e3f7 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 @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replaceAll

语法

-
const newStr = str.replaceAll(regexp|substr, newSubstr|function)
+
const newStr = str.replaceAll(regexp|substr, newSubstr|function)

当使用一个 `regex`时,您必须设置全局(“ g”)标志,
@@ -123,20 +123,20 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replaceAll

使用 replaceAll

-
'aabbcc'.replaceAll('b', '.');
+
'aabbcc'.replaceAll('b', '.');
 // 'aa..cc'

非全局 regex 抛出

使用正则表达式搜索值时,它必须是全局的。这将行不通:

-
'aabbcc'.replaceAll(/b/, '.');
+
'aabbcc'.replaceAll(/b/, '.');
 TypeError: replaceAll must be called with a global RegExp
 

这将可以正常运行:

-
'aabbcc'.replaceAll(/b/g, '.');
+
'aabbcc'.replaceAll(/b/g, '.');
 "aa..cc"
 
-- cgit v1.2.3-54-g00ecf