Share on Google+Share on Google+

java.lang.String.replaceFirst

Advertisement
In the example, we are going to show you how to implement the replaceFirst() method in Java application.

In the example, we are going to show you how to implement the replaceFirst() method in Java application.

Generally, replaceFirst() method in Java used to replace the first substring, matching the given regular expression with the given replacement.

A simple example of replaceFirst() method.

public class example {
public static void main(String args[]) {
String xx = "test";
xx = xx.replaceFirst("t","z");
System.out.println(xx);
  }
}

the Output is:
zest

Advertisements

Posted on: March 22, 2005 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: java.lang.String.replaceFirst  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0