l********r 发帖数: 140 | 1 以前用MFC的CString, 有 replace(string, string),
可是java好象没有啊.
Java String.replace is for single char replace only.
String.replaceAll is for pattern only.
How can I replace, for example, replace all the "abc" with "efg" in a given
string? (or place ", >" with "," in a given string)
Thanks a lot. | c**g 发帖数: 274 | 2 Can you read document? as a developer, reading document is even
not considered as a basic skill (probably reading code is), no mention
JDK document is crystal clear. Pattern = Regular Expression.
String s = "abcadfsafd abc";
s.replaceAll("abc", "efg");
【在 l********r 的大作中提到】 : 以前用MFC的CString, 有 replace(string, string), : 可是java好象没有啊. : Java String.replace is for single char replace only. : String.replaceAll is for pattern only. : How can I replace, for example, replace all the "abc" with "efg" in a given : string? (or place ", >" with "," in a given string) : Thanks a lot.
|
|