/**
* 参考String.trim,加入了不连续空格nbsp;( )unicode160和汉字空格unicode12288
* @param text
* @return
*/
public static String trim(String text){
int len = text.length();
int st = 0;
char[] val = text.toCharArray();
char p;
while ((st < len) && ((p=val[st]) <= ' ' || p==160 || p==12288 )) {
st++;
}
while ((st < len) && ((p =val[len - 1]) <= ' ' || p==160 || p==12288 )) {
len--;
}
return ((st > 0) || (len < text.length())) ? text.substring(st, len) : text;
}
标签:trim,String,int,text,len,st,nbsp,字符串,去掉
From: https://blog.51cto.com/chengzheng183/6458117