replace string with regex java code example
Example 1: java replace character in string
String s = "new String";
String replaced = s.replace("new","Test");
^ ^
old new char
Example 2: java string regexp replace
String input = "abcd";
Pattern p = Pattern.compile("regexp");
String output = p.matcher(input).replaceAll("replacement");