我需要从字符串中获取 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;
}
最佳答案
关于Java正则表达式获取JSON模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28644136/