java提取字符串的正则表达式

数据格式:
{"collectTime":"2015-11-11 10:08:27","dateTime":"1447207707612,"hostName":"SW-ADMIN-S5750-A0102","instanceId":"26054","metricId":"outDiscardsRate","metricName":"发送丢包率","metricValue":0,"resourceId":"RuijieSwitch","sonInstanceId":"","sonInstanceName":""}

目前匹配两个","之前的可以Pattern p = Pattern.compile("(.*?,){2}");
匹配一个","之后的也可以Pattern p = Pattern.compile("(?<=((.*,))).*");

​匹配两个","之后的Pattern p = Pattern.compile("(?<=((.*,){2})).*"); 这样会报错
怎么匹配两个","之后的内容呢?

2个回答

Java code

public static void main(String[] args) {
String source = "first {test} is here,two {test2} is here!";
String find = "\u007B.*\u007D";
Pattern pattern = Pattern.co......
答案就在这里:java 正则表达式 提取字符串
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

Pattern p = Pattern.compile("(?<=((.*?,){2})).*");

加上一个问号

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐