Returns the input string with the part(s) matching the regular expression replaced with the replacement string. If the global flag is set, replaces all matches of the regular expression. Otherwise, replaces the first match of the regular expression. As per Javascript semantics, backslashes in the replacement string get no special treatment, but the replacement string can use the following special patterns:
- $1, $2, ... $99 - inserts the n'th group matched by the regular expression.
- $& - inserts the entire string matched by the regular expression.
- $$ - inserts a $.
Note: $` and $' are *not* supported in the pure Java implementation, and throw an exception.
@param input the string in which the regular expression is to be searched.
@param replacement the replacement string.
@return the input string with the regular expression replaced by thereplacement string.
@throws RuntimeException if {@code replacement} is invalid