Java replaceall CharAt Example
String class replaceall method example
String class replaceall method example. This example shows you how to use replaceall method.This method Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.
Here is the code:-
/*
* @(#) Replaceallstring.java
*Program Shows a class replacing each substring of this string that matches the given regular expression with the given replacement.
* @Version 01-May-2008
* @author Rose India Team
*/
class Replaceallstring
{
public static void main(String[] args)
{
// Declaration of String
String s=" Welcome to Rose to India to .net to";
// Replaces each substring of this string that matches the given regular expression with the given replacement.
String c=s.replaceAll("to","" );
System.out.println("Old String :-" +s);
System.out.println("New String :-" +c);
}
} |
null
|