1 import { escapeRegex, getMatches } from '@proton/shared/lib/helpers/regex';
2 import { normalize } from '@proton/shared/lib/helpers/string';
4 export const matchChunks = (haystack: string, needle: string) => {
5 if (!needle) return [];
7 const searchWords = escapeRegex(normalize(needle)).trim().replace(/\s+/g, '|');
8 const regex = new RegExp(searchWords, 'gi');
9 return getMatches(regex, normalize(haystack));