1
This commit is contained in:
@@ -60,7 +60,7 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
private IOuterIdGeneratorService outerIdGeneratorService;
|
||||
|
||||
/**
|
||||
* 清理文本中的所有URL链接
|
||||
* 清理文本中的所有URL链接(保留换行符)
|
||||
*
|
||||
* @param text 原始文本
|
||||
* @return 清理后的文本
|
||||
@@ -74,9 +74,12 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
// 匹配到空格、换行或中文字符为止
|
||||
String cleaned = text.replaceAll("https?://[^\\s\\u4e00-\\u9fa5]+", "");
|
||||
|
||||
// 清理可能留下的多余空白和换行
|
||||
cleaned = cleaned.replaceAll("\\s+", " ");
|
||||
cleaned = cleaned.replaceAll("^\\s+|\\s+$", "");
|
||||
// 清理URL删除后可能留下的连续空格(但保留换行符)
|
||||
// 只将连续的空格或制表符替换为单个空格,不处理换行符
|
||||
cleaned = cleaned.replaceAll("[ \\t]+", " ");
|
||||
|
||||
// 清理每行开头和结尾的多余空格(但保留换行符)
|
||||
cleaned = cleaned.replaceAll("(?m)^[ \\t]+|[ \\t]+$", "");
|
||||
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user