/**
* 转义RegExp字符串中特殊的字符"^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", "|"
* Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
* "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
* @param {string} [string=''] The string to escape
* @returns {string} Returns the escaped string
* @example
* escapeRegExp('[lodash](https://lodash.com/)')
* // => '\[lodash\]\(https://lodash\.com/\)'
*/
import toString from "./toString"
// Used to match `RegExp`
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g
var reHasRegExpChar = new RegExp(reRegExpChar.source)
function escapeRegExp(string) {
转义RegExp字符串中特殊的字符"^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", "|"
最新推荐文章于 2023-02-03 14:40:46 发布