|
@@ -65,7 +65,7 @@ public class StringUtil {
|
|
|
*/
|
|
|
public static String remove_ctl(String str) {
|
|
|
String trim = "";
|
|
|
- if(StringUtils.isNotEmpty(str)){
|
|
|
+ if (StringUtils.isNotEmpty(str)) {
|
|
|
trim = str.replaceAll("\r|\n|\r\n|/r/n", "").trim();
|
|
|
}
|
|
|
return trim;
|
|
@@ -81,7 +81,7 @@ public class StringUtil {
|
|
|
if (isBlank(str)) {
|
|
|
return str;
|
|
|
}
|
|
|
- return str.replaceAll("[\\s\\p{Zs}]", "").replaceAll(" ","");
|
|
|
+ return str.replaceAll("[\\s\\p{Zs}]", "").replaceAll(" ", "");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -195,11 +195,11 @@ public class StringUtil {
|
|
|
* @param target
|
|
|
* @return
|
|
|
*/
|
|
|
-// public static boolean isSameContent(List<String> source, List<String> target) {
|
|
|
-// Set<String> sourceSet = Sets.newHashSet(source);
|
|
|
-// Set<String> targetSet = Sets.newHashSet(target);
|
|
|
-// return Sets.difference(sourceSet, targetSet).isEmpty() && Sets.difference(targetSet, sourceSet).isEmpty();
|
|
|
-// }
|
|
|
+ // public static boolean isSameContent(List<String> source, List<String> target) {
|
|
|
+ // Set<String> sourceSet = Sets.newHashSet(source);
|
|
|
+ // Set<String> targetSet = Sets.newHashSet(target);
|
|
|
+ // return Sets.difference(sourceSet, targetSet).isEmpty() && Sets.difference(targetSet, sourceSet).isEmpty();
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
|
* 解析时间
|
|
@@ -231,7 +231,7 @@ public class StringUtil {
|
|
|
* @param datetime
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Date parseDateTime(String datetime,String[] dateFormats) {
|
|
|
+ public static Date parseDateTime(String datetime, String[] dateFormats) {
|
|
|
Date date = null;
|
|
|
try {
|
|
|
datetime = remove_ctl(datetime);
|
|
@@ -266,14 +266,38 @@ public class StringUtil {
|
|
|
|
|
|
/**
|
|
|
* 去除字符串两边空白 包含一些特殊空格
|
|
|
+ *
|
|
|
* @param msg
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String trim(String msg){
|
|
|
- if (isNotBlank(msg)){
|
|
|
+ public static String trim(String msg) {
|
|
|
+ if (isNotBlank(msg)) {
|
|
|
return org.springframework.util.StringUtils.trimWhitespace(msg).trim();
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 去掉尾部几位符合字符
|
|
|
+ *
|
|
|
+ * @param value
|
|
|
+ * @param regex
|
|
|
+ * @param len
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String removeWN(String value, String regex, int len) {
|
|
|
+ String ret = null;
|
|
|
+ if (StringUtil.isNotBlank(value) && value.length() >= len) {
|
|
|
+ String endStr = null;
|
|
|
+ for (int i = len; i > 0; i--) {
|
|
|
+ endStr = value.substring(value.length() - len);
|
|
|
+ if (endStr.replaceAll(regex, "").length() == 0) {
|
|
|
+ ret = value.substring(0, value.length() - len);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
}
|