Please correct me if I am wrong.
I want to replace substring in a string in java. And I want to use String.replace(CharSequence target, CharSequence replacement) method.
I do not use regular expressions in target substring and I think this method is a good choice.
This method will work properly even there will be special regexp symbols in target substring and it will just ignore regexp format and treat target substring as a regular string.
Am I right?
Thank you.
Yes, if you use
replacethe arguments will be treated as ordinary strings, not regular expressions.If you want to replace using an regular expression you need to use
replaceAll.