首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java除去字符串中的空格、回车、换行符、制表符

2012-10-08 
java去除字符串中的空格、回车、换行符、制表符 .?/**? * 去除字符串中所包含的空格(包括:空格(全角,半角)、制

java去除字符串中的空格、回车、换行符、制表符 .

?/**
? * 去除字符串中所包含的空格(包括:空格(全角,半角)、制表符、换页符等)
? * @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;
?}

热点排行