diff --git a/src/tools/utils.ts b/src/tools/utils.ts index b6aa32a..90e7ca9 100644 --- a/src/tools/utils.ts +++ b/src/tools/utils.ts @@ -68,8 +68,9 @@ export function wait(ms: number): Promise { } // https://stackoverflow.com/a/3561711 +// but we enclose special chars in brackets to avoid them being interpreted as regex export function escapeRegex(str: string): string { - return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '[$&]') } /**