/** * 模糊匹配函数,判断 target 的字符是否按顺序出现在 source 中 * @param source 源字符串 * @param target 目标字符串 * @returns 是否匹配 */ export function fuzzyMatchBySequence(source: string, target: string): boolean { const sourceLower = source.toLowerCase(); const targetLower = target.toLowerCase(); let i = 0; let j = 0; while (i < sourceLower.length && j < targetLower.length) { if (sourceLower[i] === targetLower[j]) { j++; } i++; } return j === targetLower.length; }