取“color:”后到第一个“]” 的 red

解决方案 »

  1.   

    或者是取font-size: 后的16px
      

  2.   

    Pattern p = Pattern.compile(":(.*?)\\]");
    Matcher m = p.matcher(detail);
    while (m.find()) {
    System.out.println(m.group(1));
    }
      

  3.   


    var str = "[color:red][font-size:16px]addddddddddddddddddddddddd[/font-size][/color]";
    reg = ":(.*?)\\]";
    var s = str.replace(reg, "10px");
    alert(s);打出来的s 和str一样 不是应该10px替换了red和16px吗
      

  4.   

    var str = "[color:red][font-size:16px]addddddddddddddddddddddddd[/font-size][/color]";
    var s = str.replace(/(:)(.*?)(\])/g, "$110px$3");
    alert(s);