import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author chzeze
* 2016-11-07
*/
public class StringUtils {
public static String replaceBlank(String str) {
String dest = "";
if (str != null) {
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
dest = m.replaceAll("");
}
return dest;
}
public static void main(String[] args) {
System.out.println(StringUtils.replaceBlank("just do it!"));
}
/*----------------------------------- 笨方法:String s = "你要去除的字符串"; 1.去除空格:s = s.replace('\\s',''); 2.去除回车:s = s.replace('\n',''); 这样也可以把空格和回车去掉,其他也可以照这样做。 注:\n 回车(\u000a)
\t 水平制表符(\u0009)
\s 空格(\u0008)
\r 换行(\u000d)*/
}

最新文章

  1. 2016百度之星 资格赛ABCDE
  2. Magento显示多货币,Magento 多货币设置
  3. ubuntu 安装 netbeans C++ IDE
  4. mysql 定义自增
  5. git checkout 命令详解
  6. iOS小技巧3
  7. SSIS hang with unhandle exception
  8. 使用soapui调用webservice接口
  9. python数据分析师面试题选
  10. maven配置开发
  11. C++ STL算法系列1---count函数
  12. S2 结业考试前改错汇总
  13. linkin大话面向对象--封装和隐藏
  14. 黑盒测试实践——day03
  15. SD卡与FAT32系统学习
  16. Spring MVC 注解 @RequestParam解析
  17. 【Linux】war包的解压与压缩
  18. CSS小技巧(一)
  19. MySQL 数据类型总结及选取准则
  20. jQuery实现清空table表格除首行外的所有数据

热门文章

  1. Linux学习笔记(二)2015.4.14
  2. Object.ReferenceEquals
  3. javascript的propertyIsEnumerable()方法使用介绍
  4. robots.txt的介绍和写作
  5. Lua之元表
  6. Python之路【第十一篇续】前端之CSS补充
  7. js其它
  8. 在VS2013中强制IIS Express应用程序池使用经典模式
  9. Hello World(本博客启程篇)
  10. [CentOS]安装命令行终端Terminator工具