public String replaceAll (String regex, String replacement)

Replaces each substring of this string that matches the given regular expression with the given replacement.

An invocation of this method of the form str.replaceAll(regex, repl) yields exactly the same result as the expression


Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string; see Matcher.replaceAll. Use java.util.regex.Matcher.quoteReplacement to suppress the special meaning of these characters, if desired.

regex     the regular expression to which this string is to be matched
replacement     the string to be substituted for each match

Returns:  The resulting String

PatternSyntaxException     if the regular expression's syntax is invalid

See also:

Since:  1.4

@spec JSR-51