Commit 5d114b7cc3696cde9c37cc0a26fbb681dd690337

Authored by yanghl
1 parent 3a6a98d5

文字替换符号处理。

src/main/java/com/xly/util/AdvancedSymbolRemover.java
@@ -29,20 +29,20 @@ public class AdvancedSymbolRemover { @@ -29,20 +29,20 @@ public class AdvancedSymbolRemover {
29 text = text.replaceAll(" ", ""); 29 text = text.replaceAll(" ", "");
30 30
31 // 去掉数字末尾无用的 .0 .00 31 // 去掉数字末尾无用的 .0 .00
32 - text = text.replaceAll("(?<=\\d)\\.0+(?!\\d)", ""); 32 + text = text.replaceAll("(?<=\\d)\\.0+(?!\\d)", " ");
33 33
34 // 去掉无用文字 34 // 去掉无用文字
35 text = text.replaceAll("换一换", ""); 35 text = text.replaceAll("换一换", "");
36 36
37 // 去掉 -,但保留负数 37 // 去掉 -,但保留负数
38 - text = text.replaceAll("(?<!\\d)-(?![\\d.])|(?<=\\d)-", ""); 38 + text = text.replaceAll("(?<!\\d)-(?![\\d.])|(?<=\\d)-", " ");
39 39
40 // ============================ 40 // ============================
41 // 🔥 修正版:保留 中文、英文、数字、小数点、负号、空格 41 // 🔥 修正版:保留 中文、英文、数字、小数点、负号、空格
42 // 🔥 额外保留:中文标点 。,、;:?! 42 // 🔥 额外保留:中文标点 。,、;:?!
43 // 只删除 * # @ % ^ & 等特殊符号 43 // 只删除 * # @ % ^ & 等特殊符号
44 // ============================ 44 // ============================
45 - text = text.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5\\-. 。,、;:?!]", ""); 45 + text = text.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5\\-. 。,、;:?!]", " ");
46 46
47 // 多余空格变成单个空格(更干净) 47 // 多余空格变成单个空格(更干净)
48 text = text.replaceAll("\\s+", " ").trim(); 48 text = text.replaceAll("\\s+", " ").trim();