Sometimes we need to replace some characters with some other set of characters. To replace a Case-Insensitive chars from string you can use the below example:
package com.demo;
public class TestApps {
/*
*@param args
*/
public static void main(String[] args){
String s = "This is to replace Check String check with pattern.";
String b = s.replaceAll("(?i:check)", "#@!*");
System.out.println(b);
}
}
output:
This is to replace #@!* String #@!* with pattern.
in the above example I'm replacing chars "check", it will replace both String "Check" and "check".
Hope this will help you :)
0 Comment(s)