编程语言
首页 > 编程语言> > java中正则表达式替换字符串中的中括号

java中正则表达式替换字符串中的中括号

作者:互联网


//替换成空字符串

String  ss = "[a12,da,das]";

String replaceAll = ss.replaceAll("[\\[\\]]","");

System.out.println(replaceAll);// a12,da,das



//替换小括号同样原理

String  ss = "(a12,da,das)";
String replaceAll = ss.replaceAll("[\\(\\)]","");
System.out.println(replaceAll);// a12,da,das

标签:java,String,a12,正则表达式,da,ss,replaceAll,中括号,das
来源: https://www.cnblogs.com/nongzihong/p/16141738.html