请教jdk1.4 ReplaceAll的用法
我的测试代码
String phoneFromDB = "13611111111,13622222222,13633333333;13644444444;13655555555 ";
System.out.println( "phoneFromDB: "+phoneFromDB);
phoneFromDB.replaceAll( ", ", ", ");
phoneFromDB.replaceAll( "; ", ", ");
phoneFromDB.replaceAll( "; ", ", ");
System.out.println( "after replace: "+phoneFromDB);
希望可以把字符串中的中文逗号和中英文分号都替换成英文逗号
可是这样写结果是
phoneFromDB: 13611111111,13622222222,13633333333;13644444444;13655555555
after replace: 13611111111,13622222222,13633333333;13644444444;13655555555
repalceAll方法没有起作用
------解决方案--------------------String phoneFromDB = "13611111111,13622222222,13633333333;13644444444;13655555555 ";
System.out.println( "phoneFromDB: "+phoneFromDB);
phoneFromDB =phoneFromDB.replaceAll( ", ", ", ");
phoneFromDB =phoneFromDB.replaceAll( "; ", ", ");
phoneFromDB =phoneFromDB.replaceAll( "; ", ", ");
System.out.println( "after replace: "+phoneFromDB);