Jesus lives
Originally posted by bart zagers: Well, the behavior is mentioned in the Javadoc. Apparently, the backslash and the $-sign have a special meaning and you have to do it like: str = str.replaceAll("'", Matcher.quoteReplacement("\\'"));