新增 StringUtils.trim2 方法,去除左右空格,支持清理中文空格

This commit is contained in:
thinkgem
2018-11-09 22:24:27 +08:00
parent 7b3bba8b99
commit 55d7526c73

View File

@@ -85,6 +85,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
}
return false;
}
/**
* 去除左右空格(包含中文空格)
* @param str
*/
public static String trim2(final String str) {
return str == null ? null : str.replaceAll("^[\\s| | ]*|[\\s| | ]*$", "");
}
/**
* 替换掉HTML标签方法