日期:2014-05-20  浏览次数:20575 次

我有一个字符串,需要取得":"和","中的每一段.应该怎样做啊?
例如:
用户 [ID:86, 用户名:goudezong, 密码:123456, 用户类型:普通用户,]
我要取得 : 和 , 间的 goudezong 123456 普通用户 该怎么做啊?
则正表达式 ? split ? 求解

------解决方案--------------------
Java code

String str = "[ID:86, 用户名:goudezong, 密码:123456, 用户类型:普通用户,]";
        Pattern p = Pattern.compile(":([^,]+),");
        Matcher m = p.matcher(str);
        while(m.find()){
            System.out.println(m.group(1));
        }