JAVA截取所有指定字符后面的字符串

"a:2:{i:31;s:26:\"中国\t河北省\t保定市\";i:53;s:36:\"中国\t河北省\t保定市\t竞秀区\";}"

这个字符串,我要取出每个i:后面数字(31和53),怎么做


    public static void main(String[] args) {
        String str = "a:2:{i:31;s:26:\"中国\t河北省\t保定市\";i:53;s:36:\"中国\t河北省\t保定市\t竞秀区\";}";
        Matcher matcher = Pattern.compile("i:\\d+").matcher(str);
        while (matcher.find()) {
            System.out.println(matcher.group().substring(2));
        }
    }

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-08-19
for(i=0;i<文字长度-4;i++)
{
从i开始取4位,判断前两位是不是i:
是就取后面2位。
}本回答被提问者采纳
相似回答