if i have some string e.g:
String s = "This is a string";
And now i perform this action:
s = s.replaceAll("This","What");
It works, with s = "What is a string"
fine, but now if the expression was not a match:
s = s.replaceAll("junk","What");
s remains what it was before, i.e s = "This is a string";
I want to know, without equating these strings, is there a way to know if s.replaceAll really performed some action or not??
would it be ok if you try
if(s.contains("junk"))
s.replaceAll("junk", "What");
else
//you know it hasn't executed!