本文介绍了Java:找不到字符串替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
mystring.replace() 没有在我的文本中找到所有内容,例如:
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");
我已经检查了 str
和 replace
但替换仍然没有做任何事情!str
里面完全有替换字符串.
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!?
推荐答案
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.
这篇关于Java:找不到字符串替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!