7 lines
228 B
TypeScript
7 lines
228 B
TypeScript
// credits to https://github.com/sindresorhus/escape-string-regexp/blob/master/index.js
|
|
export default function escapeRegExp(str: string) {
|
|
return str
|
|
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
.replace(/-/g, '\\x2d');
|
|
}
|