Java String.replaceAll(String regex, String replacement)
Syntax
String.replaceAll(String regex, String replacement) has the following syntax.
public String replaceAll(String regex, String replacement)
Example
In the following code shows how to use String.replaceAll(String regex, String replacement) method.
public class Main {
//from w ww . j a v a2 s .com
public static void main(String args[]) {
String str = "This is a test from java2s.com.";
System.out.println(str.replaceAll("is", "are"));
}
}
The code above generates the following result.