![]() |
VOOZH | about |
The replaceFirst() method of Matcher Class behaves as an append-and-replace method. This method reads the input string and replaces it with the first matched pattern in the matcher string.
Syntax:
public String replaceFirst(String stringToBeReplaced)
Parameters: The string to be replaced that is the String to be replaced in the matcher.
Return Type: A string with the target string constructed by replacing the string.
Example 1:
Before Replacement: GeeksForGeeks Geeks for For Geeks Geek After Replacement: GFGForGeeks Geeks for For Geeks Geek
Example 2:
Before Replacement: FGF FGF FGF FGF After Replacement: GFG FGF FGF FGF