mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-19 07:44:45 +08:00
Update
This commit is contained in:
10
backend/src/utils/index.ts
Normal file
10
backend/src/utils/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export function cleanHtmlTags(text: string): string {
|
||||
if (!text) return "";
|
||||
return text
|
||||
.replace(/<[^>]+>/g, "\n") // 将 HTML 标签替换为换行
|
||||
.replace(/\n+/g, "\n") // 将多个连续换行合并为一个
|
||||
.replace(/[ \t]+/g, " ") // 将多个连续空格和制表符合并为一个空格,但保留换行符
|
||||
.replace(/^\n+|\n+$/g, "") // 去掉首尾换行
|
||||
.replace(/ /g, " ") // 将 替换为空格
|
||||
.trim(); // 去掉首尾空格
|
||||
}
|
||||
Reference in New Issue
Block a user