Commit 101a0d7a5166516e4cd27f2e9414879685af0a30
1 parent
d7b26d3f
Exists in
master
1.去除首尾空格时调用 去除特殊字符
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
build.gradle
src/main/java/com/taover/util/UtilString.java
... | ... | @@ -20,6 +20,8 @@ public class UtilString { |
20 | 20 | return ""; |
21 | 21 | } |
22 | 22 | |
23 | + source = replaceCodePage(source, ""); | |
24 | + source = replaceNoBreakBackspace(source, ""); | |
23 | 25 | Pattern pattern = Pattern.compile("\\S"); |
24 | 26 | int startIndex = -1; |
25 | 27 | for(int i=0; i<source.length(); ++i){ |
... | ... | @@ -44,6 +46,8 @@ public class UtilString { |
44 | 46 | return ""; |
45 | 47 | } |
46 | 48 | |
49 | + source = replaceCodePage(source, ""); | |
50 | + source = replaceNoBreakBackspace(source, ""); | |
47 | 51 | Pattern pattern = Pattern.compile("\\S"); |
48 | 52 | int endIndex = source.length()-1; |
49 | 53 | for(int i=source.length()-1; i>=0; --i){ |
... | ... | @@ -93,10 +97,19 @@ public class UtilString { |
93 | 97 | return ""; |
94 | 98 | } |
95 | 99 | |
100 | + @Deprecated | |
96 | 101 | public static String trimCodePage(String data){ |
97 | 102 | return data.replaceAll(new String(new byte[]{-30, -128, -83}), ""); |
98 | 103 | } |
99 | 104 | |
105 | + public static String replaceCodePage(String data, String replaceStr){ | |
106 | + return data.replaceAll(new String(new byte[]{-30, -128, -83}), replaceStr); | |
107 | + } | |
108 | + | |
109 | + public static String replaceNoBreakBackspace(String data, String replaceStr) { | |
110 | + return data.replaceAll(new String(new byte[] {-62, -92}), replaceStr); | |
111 | + } | |
112 | + | |
100 | 113 | /** |
101 | 114 | * 在compares字符数组查找pattern字符串,找到则返回字串在数组中的索引,未找到返回-1 |
102 | 115 | * @param pattern | ... | ... |