我需要从String
获取JSON对象在此字符串中,JSON内容对于此表单是唯一的:
abit2:{....};
我以这种方式制作了我的正则表达式,但我无法以分号停止
public String getJSON(String content) throws MalformedURLException, IOException{
String json = "";
String regex = "abit2:([\\s\\S]*)\\};";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
json = matcher.group().replace("abit2:", "");
}
return json;
}
答案 0 :(得分:1)