Java??replace??replaceAll??????
???????????? ???????[ 2014/11/5 11:13:23 ] ????????Java ????? ????
????replace??replaceAll??JAVA?г?????滻?????????????????????:
????1)replace???????char??CharSequence?????????????????滻??????????????滻(CharSequence??????????е???????????????????);
????2)replaceAll???????regex?????????????????滻?????磬???????replaceAll("\d"?? "*")?????????????е?????????????????;
??????????????????滻?????????????е????????????????????????????????????????????滻????γ???????????? replaceFirst()????????????????????????滻??????replaceAll()??????????滻????γ?????????;
???????????replaceAll()??replaceFirst()?????????????????????????????replace()?滻???????Ч????????????????????????????????;
??????????????:??????滻??????????????????????з???????.
????????????:
String src = new String("ab43a2c43d");
System.out.println(src.replace("3"??"f"));=>ab4f2c4fd.
System.out.println(src.replace('3'??'f'));=>ab4f2c4fd.
System.out.println(src.replaceAll("\d"??"f"));=>abffafcffd.
System.out.println(src.replaceAll("a"??"f"));=>fb43fc23d.
System.out.println(src.replaceFirst("\d??"f"));=>abf32c43d
System.out.println(src.replaceFirst("4"??"h"));=>abh32c43d.
??????ν???????е?""?滻??"\"??
????String msgIn;
????String msgOut;
????msgOut=msgIn.replaceAll("\\"??\\\\);
????ps:ò????????????msgIn = msgIn.replaceAll("\\"??\\\\);
???????
????''??java?????????????????????????????????????????System.out.println( "\" ) ;?????????""??????''???????????е?????????replaceAll ?????????????????????????????????????????\\??java?????\??\??????????????ɡ?
???????
????CODE: \\\\
????Java: \\
????Regex: \
????????????е?'/'?滻??''???????:
????msgOut= msgIn.replaceAll("/"?? "\\");
????msgOut= msgIn.replace("/"?? "\");
????msgOut= msgIn.replace('/'?? '\');
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11