我就废话不多说,大家还是直接看代码吧~
String abc1 = "百度科技(123)公司1";
abc1 = abc1.replaceAll("\(|\)", "");
System.out.println(abc1);
String abc2 = "百度科技(123)公司2";
abc2 = abc2.replaceAll("(","").replaceAll(")","");
System.out.println(abc2);
补充知识:java用正则匹配中文中括号,和英文中括号
String regex = "(?<=\[)(\S+)(?=\])|(?<=【)[^】]*";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(sss.get(i));
while (matcher.find()) {matcher.get(0)}
以上这篇java去除中文括号小括号,或者英文括号的实例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持考高分网。



