Java replace and replaceAll

Both replace and replaceAll methods will replace all matches in the String. The difference is that replaceAll uses the regular expression, while replace just use the String literal.

What if you only want to replace only the first match? Use the replaceFirst method.