1. 程式人生 > >字串去除換行、空格

字串去除換行、空格

String nets = "";
if (nets!=null) {
        	/* 去除      \n 回車(\u000a) \t 水平製表符(\u0009) \s 空格(\u0008)\r 換行(\u000d)*/
            Pattern p = Pattern.compile(""\\s*|\t|\r|\n"");
            Matcher m = p.matcher(nets);
            dest = m.replaceAll("");
        }