lodash escapeRegExp 转义正则特殊字符

_.escapeRegExp([string=''])

转义RegExp 中特殊的字符 "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", 以及 "|"。

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

猜你喜欢

转载自www.cnblogs.com/mengfangui/p/9210506.html