正则替换全角空格和逗号

char blank = ' ';// 全角空格
System.out.println("\\u" + Integer.toHexString(blank));// \u3000
		
char comma = ',';// 全角逗号
System.out.println("\\u" + Integer.toHexString(comma));// \uff0c

String str = "a b" + blank + "c" + comma + "d";
System.out.println(str);// a b c,d
		
str = str.replaceAll("[\\s|\u3000|\uff0c]+", ",");
System.out.println(str);// a,b,c,d

 

你可能感兴趣的:(Java)