I have few string datasets in which I would like to replace a certain combination of characters using the regex replace in java. I tried multiple patterns but none of them helped. Could someone point me in the right pattern?
For example:
hello,[cicuyuv v,]imijmijm
in this string i want to replace ",[" and ",]" with a single "," wherever occured.
public class MainApp {
public static void main(String[] args) {
String data = "hello,[cicuyuv v,]imijmijm"
.replaceAll("[,[\\[]]", ",");
System.out.println(data);
}
}
replaceAll(",[\\[\\]]", ",")"hello,[cicuyuv v,]imijmijm".replaceAll(",[\\[\\]]", ",")try this