标签:
1、去掉所有 \r \n :
1 public static void main(String[] args) 2 { 3 String str = "A\r\nB\nc"; 4 String[] strs = str.split("[\r\n]+"); 5 for (int i=0; i<strs.length; i++) 6 System.out.println(strs[i]); 7 8 System.out.println(""); 9 10 str = "Ac\r\r\nB1\n\nc2"; 11 strs = str.split("[\r\n]+"); 12 for (int i=0; i<strs.length; i++) 13 System.out.println(strs[i]); 14 }
输出为:
1 A 2 B 3 c 4 5 Ac 6 B1 7 c2
C
标签:
原文地址:http://www.cnblogs.com/codeskilla/p/4956222.html