主题
escapeRegExp
js
_.escapeRegExp([string=''])转义 RegExp 特殊字符 "^"、"$"、""、"."、""、""、"?"、"("、")"、"["、"]"、“{", "}”和 string 中的 "|"。
¥Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.
新增于
¥Since
3.0.0
参数
¥Arguments
[string=''](字符串):要转义的字符串。¥
[string=''](string): The string to escape.
返回
¥Returns
(字符串):返回转义后的字符串。
¥(string): Returns the escaped string.
示例
¥Example
js
_.escapeRegExp('[lodash](https://lodash.nodejs.cn/)');
// => '\[lodash\]\(https://lodash\.com/\)'