replaceFirst() String Example

replaceFirst() String Example

After seeing replace() method in String, let us study another similar method replaceFirst() String.
What Java API says about the method:
  • String replaceFirst (String str, String replaceString): Replaces the first occurrence of str in the original string(calling string) with replaceString, The original string is not getting disturbed, but the returned string gets effected. See example.

Following is the example.


replaceFirst() String
Output screenshot on replaceFirst() String Example

Also refer for a similar method replace().

Pass your comments and suggestions on this tutorial "replaceFirst() String Example".

Leave a Reply

Your email address will not be published. Required fields are marked *