public static String get(String str,String key){
Matcher mcr=Pattern.compile("\""+key+"\":\"([^\"]*)\"").matcher(str);
if(mcr.find()){
return mcr.group(1);
}
return null;
}
正则表达式适合于匹配找到的东西
用替换实现的思路就不对第一种可以用替换是也因为找到了那种类型,才进行替换
Matcher mcr=Pattern.compile("\""+key+"\":\"([^\"]*)\"").matcher(str);
if(mcr.find()){
return mcr.group(1);
}
return null;
}
正则表达式适合于匹配找到的东西
用替换实现的思路就不对第一种可以用替换是也因为找到了那种类型,才进行替换
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货