Davie Lin wrote:
Thanks for reading my question. According to String.java in 5, the implementation for String.replace(CharSequence, CharSequence) is
I don't quite understand how Pattern and Matcher object work, my question is does the iterate the entire string and replace the char just like
Well, we are not going to explain regular expressions here .... there are whole books dedicated to the subject. It is arguably a language itself.
Basically,
Java has a regular expression engine as part of the core libraries -- and the Pattern and Matcher classes is how you use it. As for the LITERAL and quoteReplacement() stuff, that is used to disable practically all the special features of the regular expression engine.... basically, it is using the regular expression engine to do simple string replacement.
Henry