From 7af0048fa3dd6ad8a5a3a61d826664e110193cc5 Mon Sep 17 00:00:00 2001 From: xinzejy <37665471+srq18211@users.noreply.github.com> Date: Mon, 3 May 2021 22:42:50 +0800 Subject: Update /web/javascript/reference/global_objects/regexp/regexp, zh-CN (#734) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update index.html 翻译了一小部分 * Update index.html Translated into Chinese --- .../global_objects/regexp/regexp/index.html | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/regexp') diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html index 138ebf4ba7..1457ab4f59 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html @@ -26,27 +26,27 @@ RegExp(pattern[, flags])
pattern
RegExp
object or literal (for the two RegExp constructor notations only). Patterns may include special characters to match a wider range of values than would a literal string. RegExp
对象或文字(仅用于两个RegExp构造函数符号)。模式可以包含特殊字符special characters来匹配比字面值字符串更广泛的值范围 。 flags
If specified, flags
is a string that contains the flags to add.
如果指定, flags
是包含要添加的标志的字符串。
Alternatively, if an object is supplied for the pattern, the flags
string will replace any of that object's flags (and lastIndex
will be reset to 0
) (as of ES2015).
或者,如果为模式提供了一个对象,flags字符串将替换该对象的任何标志(并且lastIndex
将重置为0)(从ES2015开始)。
如果没有指定flags
并且提供了一个正则表达式对象,则该对象的flags(和lastIndex值)将被复制。
If flags
is not specified and a regular expressions object is supplied, that object's flags (and lastIndex
value) will be copied over.
flags
may contain any combination of the following characters:
flags
可包含下列任何字符的组合:
g
(全局匹配)i
(忽略大小写)u
flag is also enabled, use Unicode case folding.u
标志也被启用,使用Unicode大小写折叠。m
(多行匹配)^
and $
) as working over multiple lines. In other words, match the beginning or end of each line (delimited by \n
or \r
), not only the very beginning or end of the whole input string.^
and $
)视为在多行上工作。换句话说,匹配每一行的开头或结尾each line (由\n
或者\r
分隔),而不仅仅是整个输入字符串的开头或结尾。s
(点号匹配所有字符).
to match newlines..
去匹配新的行u
(unicode)pattern
as a sequence of Unicode code points. (See also Binary strings).y
(sticky,粘性匹配)There are two ways to create a RegExp
object: a literal notation and a constructor.
这里有两种方法创建RegExp
对象: 字面量 和 构造函数.
The following three expressions create the same regular expression:
+以下三个表达式创建相同的正则表达式:
/ab+c/i -new RegExp(/ab+c/, 'i') // literal notation -new RegExp('ab+c', 'i') // constructor +new RegExp(/ab+c/, 'i') // 字面量 +new RegExp('ab+c', 'i') // 构造函数-
The literal notation results in compilation of the regular expression when the expression is evaluated. Use literal notation when the regular expression will remain constant. For example, if you use literal notation to construct a regular expression used in a loop, the regular expression won't be recompiled on each iteration.
+当表达式被求值时,文字表示法会导致对正则表达式的编译。当正则表达式保持不变时,请使用字面量表示法。例如,如果使用字面量表示法来构造循环中使用的正则表达式,则不会在每次迭代时重新编译正则表达式。
-The constructor of the regular expression object—for example, new RegExp('ab+c')
—results in runtime compilation of the regular expression. Use the constructor function when you know the regular expression pattern will be changing, or you don't know the pattern and are getting it from another source, such as user input.
正则表达式对象的构造函数—例如,new RegExp('ab+c')—会导致正则表达式的运行时编译。当您知道正则表达式模式将发生变化时,或者您不知道该模式,但正在从其他来源(如用户输入)获取它时,请使用构造函数。
Specification | +技术规范 |
---|