Java去除字符串中的空白字符呢?
下文笔者讲述“去除字符串”中“空白字符”的方法分享
去除字符串的实现思路: 使用正则表达式“去除字符串”即可剔除“空白字符”例
protected String replaceBlank(String str){ String dest = null; if(str == null){ return dest; }else{ Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); return dest; } }
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。