[code="java"]
string.replaceFirst(re, "")
和
Pattern pattern =Pattern.compile(re);
Matcher matcher=pattern.matcher(string);
匹配的好像不太一样啊(不是指数量。。)
[/code]
String str="{ba:'bababa',a:'we',b:'w',aa:'haha'}";
String re="(?<=(\{|,)"+key+":').*?(?=')";
System.out.println(json.replaceFirst(re, ""));
和pattern.matcher(str);
结果不一样,后面的方式根本没有匹配到
如果我采用第一种方式,我怎么能返回正则所匹配的内容