java replaceAll error

public String replaceAll(String regex, String replacement)

This method works fine if replacement string does not contain ‘$’ or ‘/’ characters.If replacement string contains these characters, the results can be in-accurate.

Fix: Use Matcher.quoteReplacement(replacement)

public String replaceAll(String regex,
        Matcher.quoteReplacement(replacement))

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.