|
|
@@ -795,6 +795,20 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|
|
if (str == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- return str.replaceAll("[,,]{2,}", "; 或 ");
|
|
|
+ return str.replaceAll("[,,]{2,}", ";\t或\t");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将字符串中两个及以上相邻的逗号(中文","或英文",")合并为一个逗号(中文",")
|
|
|
+ * 例如:"a,,b" -> "a,b";"a,,b" -> "a,b";"a,b"(单个逗号)保持原样
|
|
|
+ *
|
|
|
+ * @param str 原始字符串,可为null
|
|
|
+ * @return 替换后的字符串,若入参为null则返回null
|
|
|
+ */
|
|
|
+ public static String mergeAdjacentComma(String str) {
|
|
|
+ if (str == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return str.replaceAll("[,,]{2,}", ";\t\t");
|
|
|
}
|
|
|
}
|