The replaceFirst() method — replaces the first substring of this string, which corresponds to the specified regular expression, with this substitution, in other words, the method in Java allows you to replace the first occurrence of a word or phrase in a string.
Syntax
Syntax method:
Options
Detailed information about the parameters:
regex is a regular expression to which this string must match;
replacement is a string that will replace the expression found.
Return value
In Java, replaceFirst () returns the result string.