第一页(产品功效:)[可以美容养颜](味道:)[酸甜苦辣]第2页提交后  应得到:<font color=bule>产品功效:</font> <font color=blue>可以美容养颜</font>
          <font color=bule>味道:</font> <font color=blue>酸甜苦辣</font>要求,只能用StringTokenizer(),正则表达式,就不要来浪费时间了。。

解决方案 »

  1.   

    错了
    其实就是用<font color=bule>替换(, 用</font>替换).用[替换<font color=red>,用]替换</font>
      

  2.   

    用什么StringTokenizer啊,直接replaceAll()
      

  3.   

    String str = "(产品功效:)[可以美容养颜](味道:)[酸甜苦辣]";
            String rst = "";
            Pattern p = Pattern.compile("\\(([^\\(\\)]+)\\)\\[([^\\[\\]]+)\\]");
            Matcher m = p.matcher(str);
            while (m.find()) {
                rst += "<font color=bule>" + m.group(1) + "</font> <font color=blue>"
                        + m.group(2) + "</font>";
            }
            System.out.println(rst);
            
            str=str.replaceAll("\\(","<font color=bule>");
            str=str.replaceAll("\\)","</font>");
            str=str.replaceAll("\\[","<font color=bule>");
            str=str.replaceAll("\\]","</font>");
            System.out.println(str);
      

  4.   

    StringTokenizer stk = new StringTokenizer("(产品功效:)[可以美容养颜](味道:)[酸甜苦辣]","()[]");
    String part_1 = stk.hasMoreTokens()?stk.nextToken():"";
    String part_2 = stk.hasMoreTokens()?stk.nextToken():"";
    String part_3 = stk.hasMoreTokens()?stk.nextToken():"";
    String part_4 = stk.hasMoreTokens()?stk.nextToken():"";
    依次得到 
    1、产品功效:
    2、可以美容养颜
    3、味道:
    4、酸甜苦辣然后拼起来吧