VOOZH about

URL: https://www.geeksforgeeks.org/scala/scala-string-replacefirst-method-with-example/

⇱ Scala String replaceFirst() method with example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Scala String replaceFirst() method with example

Last Updated : 3 Oct, 2019
The replaceFirst() method is same as replaceAll but here only the first appearance of the stated sub-string will be replaced.
Method Definition: String replaceFirst(String regex, String replacement) Return Type: It returns the stated string after replacing the first appearance of stated regular expression with the string we provide.
Example #1:
Output:
##NidhimsoSingh
Example #2:
Output:
Nidhi*Singhcso
Example #3:
Output:
*NidhimsoSinghcso
Comment
Article Tags:

Explore