From 33be544dc72861d9cd9418aebb93a9f9d27dd716 Mon Sep 17 00:00:00 2001 From: mushan0x0 Date: Wed, 3 Jan 2024 12:09:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20outdated=20browser=20erro?= =?UTF-8?q?r=20(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/utils/splitTextIntoSegments.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/utils/splitTextIntoSegments.ts b/src/core/utils/splitTextIntoSegments.ts index 4c9e3d7..bcf2668 100644 --- a/src/core/utils/splitTextIntoSegments.ts +++ b/src/core/utils/splitTextIntoSegments.ts @@ -25,7 +25,7 @@ const toHalfWidthAndCleanSpace = (str: string): string => { export const splitTextIntoSegments = (text: string, maxChars: number = 100): string[] => { text = toHalfWidthAndCleanSpace(text); - const sentences = text.split(/(?<=[!.;?])/g); + const sentences = text.match(/[^.!;?]+[.!;?]+/g) || []; const segments: string[] = []; let currentSegment = '';