这是我原来的字符串:
String response = "attributes[{"id":50,"name":super},{"id":55,"name":hello}]";
我正在尝试解析字符串并提取所有id
值,例如
50
55
Pattern idPattern = Pattern.compile("{\"id\":(.*),");
Matcher matcher = idPattern.matcher(response);
while(matcher.find()){
System.out.println(matcher.group(1));
}
当我尝试打印该值时,我得到一个异常:
java.util.regex.PatternSyntaxException: Illegal repetition
过去对正则表达式没有太多经验,但在网上找不到简单的解决方案。
感谢任何帮助!