50,545
社区成员
发帖
与我相关
我的任务
分享
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));
}
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 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]);