export const isPunctuation = (char: string): boolean => { // 使用正则表达式匹配标点符号 const punctuationRegex = /[!,.;?~!,。;?!]/; // 测试字符是否是标点符号 return punctuationRegex.test(char); } export const isEndWithHuanHang = (str: string): boolean => { if (str && str.endsWith("\n") || str.endsWith("\r\n") || str.endsWith("\n\n")) { return true } else { return false } } export const isStartWithHuanhang = (str: string): boolean => { if (str && str.startsWith("\n") || str.startsWith("\r\n") || str.startsWith("\n\n")) { return true } else { return false } } export const isTextCut = (str: string): boolean => { if (str.length < 1) { return false } if (isEndWithHuanHang(str)) { return true } if (isPunctuation(str[str.length - 1])) { return true } return false } export const isTextCutHead = (str: string): boolean => { if (str.length < 1) { return false } if (isStartWithHuanhang(str)) { return true } if (isPunctuation(str[0])) { return true } return false } export const isImageURL = (url: string): boolean => { if (url.startsWith("https") || url.startsWith("http") || url.startsWith("data:image/")) { return true } else { return false } }