问题
mystring.replace() doesn't find everything in my text e.g:
replace = (CalendarInfo.Monday + " " + String.valueOf(dayofmonth) + " " + String.valueOf(CalendarInfo.Month[monthofyear]).toString());
str= str.replace(replace, "Hello");
I've check the str
and the replace
but replace still doesn't do anything! str
totally have replace string in it.
So why doesn't replace replace!?
回答1:
String str = "abcd".replace("ab", ""); //str is "cd"
That means your code works basically. But your replace string is not exactly in your source string.
回答2:
Probably because your assumption is wrong.
Maybe different count of (white) spaces, or different code (0x20 or 0xa0), or tab "\011"
来源:https://stackoverflow.com/questions/10144695/java-string-replace-doesnt-find