public String replaceFirst (String regex, String replacement)

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

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

java.util.regex.Pattern.compile(regex).java.util.regex.Pattern.matcher(java.lang.CharSequence)(str).replaceFirst(repl)

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 java.util.regex.Matcher.replaceFirst. Use java.util.regex.Matcher.quoteReplacement to suppress the special meaning of these characters, if desired.

Parameters:
regex     the regular expression to which this string is to be matched
replacement     the string to be substituted for the first match

Returns:  The resulting String

Exceptions:
PatternSyntaxException     if the regular expression's syntax is invalid

See also:
java.util.regex.Pattern

Since:  1.4

@spec JSR-51