|
/**
|
|
* 转义特殊字符
|
|
*
|
|
* @export
|
|
* @param {string} [string=''] 字符串
|
|
* @link https://github.com/sindresorhus/escape-string-regexp
|
|
*/
|
|
export function escapeStringRegexp(string = '') {
|
|
return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
|
}
|