fix:function removeDuplicateWords

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-01-12 14:47:34 +07:00
parent 6765e5d90b
commit ef04a94a69

View file

@ -22,19 +22,8 @@ const { date2Thai, messageError } = useCounterMixin();
function removeDuplicateWords(text: string): string {
if (!text) return text;
//
const words = text.split(/(?=[ก-๙])/);
const result: string[] = [];
for (let i = 0; i < words.length; i++) {
const word = words[i];
if (i === 0 || word !== words[i - 1]) {
result.push(word);
}
}
// : regex
return text.replace(/([ก-๙]+)\1+/g, "$1");
return text.replace(/([ก-๙]{2,})\1+/g, "$1");
}
/** รับ props มาจากหน้าหลัก */