Java Replaceall Example - Java

How to replace each substring in java?

Snippet Code


  
Rate this page :
  [ 0 votes]

The String.replaceAll() method replaces the matched substring in the string which is given in regular expression. The Sample code for replaceall method in jquery is given below.

stringdemo.java: import java.lang.*; public class stringdemo { public static void main(String[] args) { String str1 = "!!Hscripts!!Snippets", str2; String substr = "**", regex = "!!"; System.out.println("String = " + str1); str2 = str1.replaceAll(regex, substr); System.out.println("After Replacing = " + str2); } }

Tags


Ask Questions

Ask Question