去除開頭兩個(gè)全角字符
while(firstPara.startsWith(" ")){
firstPara = firstPara.substring(2, firstPara.length()).trim();
}
以下來源于:http://blog.csdn.net/hfhwfw/article/details/5722487
/**
* 去除字符串中所包含的空格(包括:空格(全角漓柑,半角)愤兵、制表符飞蹂、換頁符等)
* @param s
* @return
*/
public static String removeAllBlank(String s){
String result = "";
if(null!=s && !"".equals(s)){
result = s.replaceAll("[ *| *| *|//s*]*", "");
}
return result;
}
/**
* 去除字符串中頭部和尾部所包含的空格(包括:空格(全角,半角)蚀浆、制表符、換頁符等)
* @param s
* @return
*/
public static String trim(String s){
String result = "";
if(null!=s && !"".equals(s)){
result = s.replaceAll("^[ *| *| *|//s*]*", "").replaceAll("[ *| *| *|//s*]*$", "");
}
return result;
}