_.escapeRegExp(转义正则特殊字符)

语法:

_.escapeRegExp([string=''])

源代码链接:source

npm包链接:npm package

描述:

转义RegExp字符串中特殊的字符 "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", 和 "|" in .

开始版本:3.0.0

参数:

  • [string=''] (string): 要转义的字符串。

返回值:

  • (string): 返回转义后的字符串。

例子:

_.escapeRegExp('[lodash](https://lodash.com/)');
// => '\[lodash\]\(https://lodash\.com/\)'

Last updated