From e6952d262de2d8551c5c6877cde84809b8fa9fe5 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Fri, 28 Oct 2022 20:38:25 +0200 Subject: [PATCH] Highlights in excerpts now only work as word prefixes Less confusing --- src/tools/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/utils.ts b/src/tools/utils.ts index 7fe47b8..8e13bf5 100644 --- a/src/tools/utils.ts +++ b/src/tools/utils.ts @@ -70,7 +70,7 @@ export function getAllIndices(text: string, regex: RegExp): SearchMatch[] { */ export function stringsToRegex(strings: string[]): RegExp { if (!strings.length) return /^$/g - const joined = strings.map(s => escapeRegex(s)).join('|') + const joined = strings.map(s => '\\b' + escapeRegex(s)).join('|') const reg = new RegExp(`(${joined})`, 'gi') // console.log(reg) return reg