正则表达式  怎样匹配{}   小弟有个字符串"{212143523}{额4314315}{14rdfw}"怎样拿出大括号里边的字符串  在线等,十分感谢!!!

解决方案 »

  1.   


    String s ="{212143523}{额4314315}{14rdfw}" ;
    String [] ss = s.split("[\\{\\}]") ;
    for (int i = 0; i < ss.length; i++) {
    System.out.println(ss[i]);
    }
      

  2.   

    String s = "{212143523}";
    s = s.replaceAll("[\\{\\}]", "");
    System.out.println(s);
      

  3.   


    public static void main(String[] args) {
    String str = "{212143523}{额4314315}{14rdfw}";
    Matcher matcher = Pattern.compile("\\{(.*?)\\}").matcher(str);
    while (matcher.find()) {
    System.out.println(matcher.group(1));
    }
    }