gpt4 book ai didi

java - JAVA无法解析正则表达式

转载 作者:太空宇宙 更新时间:2023-11-04 12:57:58 25 4
gpt4 key购买 nike

这是我的代码,

String xyz = "{\"status\":\"ok\",\"data\":[{\"RatingCount\":4}],         [{\"RatingCount\":1}], [{\"RatingCount\":1}]\"code\":1}";
String pattern = ".*],\\s*\\[.*";//"(.*)(],\\s.*\\[)(.*)";
Pattern p1 = Pattern.compile(pattern);
Matcher m1 = p1.matcher(xyz);
boolean b = m1.matches();
System.out.println(b);

我想用 "" 替换模式 '], ['

我使用了replaceAll,但没有成功

最佳答案

Check it in working Fiddle

使用如下正则表达式

String pattern = "\],[ ]*\[";

关于java - JAVA无法解析正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35203959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com