public class replaceBracket {
public static void main(String[] args){
String Node = "万达购物中心(室内)";
String newNode = "";
if(Node.contains("(") && Node.contains(")")){
newNode = Node.replace("(", "(");
System.out.println(newNode);
}
}
}
这个方法只能替换为:万达购物中心(室内),替换了左边的中文括号但却没有替换右边的中文括号。

解决方案 »

  1.   

    if(Node.contains("(") && Node.contains(")")){
    newNode = Node.replace("(", "(");
    newNode = newNode.replace(")", ")");System.out.println(newNode);
      

  2.   

    2个replaceall就搞定public static void main(String[] args) {
    String Node = "万达购物中心(室内)";
    String s = null;
    System.out.println(s = Node.replaceAll("(", "("));
    System.out.println(s = s.replaceAll(")", ")"));
    }
      

  3.   

    对的  就用replace(“你要替换的东西”,“替换成什么”);