日期:2014-05-20 浏览次数:20631 次
String str = "\"mPrice\":369.00,\"name\":\"Adidas阿迪达斯女款运动针织长裤X25189,S\",\"onsale\":true,\"price\":221.00,\"sku\":\"20-440-8965\",\"stock\":2.00,\"styleID\":\"20-440-8964\"";
String[] ss = str.replaceAll(".*?\"name\":\"(.*?)\".*?\"price\":(.*?),.*", "$1,$2").split(",");
System.out.println(ss[0]);
System.out.println(ss[1]);
String t="\"mPrice\":369.00,\"name\":\"Adidas阿迪达斯女款运动针织长裤X25189,S\",\"onsale\":true,\"price\":221.00,\"sku\":\"20-440-8965\",\"stock\":2.00,\"styleID\":\"20-440-8964\"";
Matcher m = Pattern.compile("name\":\"(.*?)(?=\",)").matcher(t);
while (m.find()) {
System.out.println(m.group(1));
}
String t="\"mPrice\":369.00,\"name\":\"Adidas阿迪达斯女款运动针织长裤X25189,S\",\"onsale\":true,\"price\":221.00,\"sku\":\"20-440-8965\",\"stock\":2.00,\"styleID\":\"20-440-8964\"";
Matcher m = Pattern.compile("(name
------解决方案--------------------
price)\":\"?(.*?)(?=\"?,)").matcher(t);
while (m.find()) {
System. err .println(m.group(2));
}