Commit 101a0d7a5166516e4cd27f2e9414879685af0a30
1 parent
d7b26d3f
Exists in
master
1.去除首尾空格时调用 去除特殊字符
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
build.gradle
@@ -59,7 +59,7 @@ uploadArchives { | @@ -59,7 +59,7 @@ uploadArchives { | ||
59 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) | 59 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) |
60 | } | 60 | } |
61 | pom.project { | 61 | pom.project { |
62 | - version '1.1.99' | 62 | + version '1.1.100' |
63 | artifactId ARTIFACT_Id | 63 | artifactId ARTIFACT_Id |
64 | groupId GROUP_ID | 64 | groupId GROUP_ID |
65 | packaging TYPE | 65 | packaging TYPE |
src/main/java/com/taover/util/UtilString.java
@@ -20,6 +20,8 @@ public class UtilString { | @@ -20,6 +20,8 @@ public class UtilString { | ||
20 | return ""; | 20 | return ""; |
21 | } | 21 | } |
22 | 22 | ||
23 | + source = replaceCodePage(source, ""); | ||
24 | + source = replaceNoBreakBackspace(source, ""); | ||
23 | Pattern pattern = Pattern.compile("\\S"); | 25 | Pattern pattern = Pattern.compile("\\S"); |
24 | int startIndex = -1; | 26 | int startIndex = -1; |
25 | for(int i=0; i<source.length(); ++i){ | 27 | for(int i=0; i<source.length(); ++i){ |
@@ -44,6 +46,8 @@ public class UtilString { | @@ -44,6 +46,8 @@ public class UtilString { | ||
44 | return ""; | 46 | return ""; |
45 | } | 47 | } |
46 | 48 | ||
49 | + source = replaceCodePage(source, ""); | ||
50 | + source = replaceNoBreakBackspace(source, ""); | ||
47 | Pattern pattern = Pattern.compile("\\S"); | 51 | Pattern pattern = Pattern.compile("\\S"); |
48 | int endIndex = source.length()-1; | 52 | int endIndex = source.length()-1; |
49 | for(int i=source.length()-1; i>=0; --i){ | 53 | for(int i=source.length()-1; i>=0; --i){ |
@@ -93,10 +97,19 @@ public class UtilString { | @@ -93,10 +97,19 @@ public class UtilString { | ||
93 | return ""; | 97 | return ""; |
94 | } | 98 | } |
95 | 99 | ||
100 | + @Deprecated | ||
96 | public static String trimCodePage(String data){ | 101 | public static String trimCodePage(String data){ |
97 | return data.replaceAll(new String(new byte[]{-30, -128, -83}), ""); | 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 | * 在compares字符数组查找pattern字符串,找到则返回字串在数组中的索引,未找到返回-1 | 114 | * 在compares字符数组查找pattern字符串,找到则返回字串在数组中的索引,未找到返回-1 |
102 | * @param pattern | 115 | * @param pattern |