我想在我的字符串中找到正则表达式的实例。但它不起作用。我的正则表达式似乎不错。
我的字符串是这样的:
LB,32736,0,T,NRJ.POMPES_BACHE.PUISSANCE_ELEC_INST,20190811T080000.000Z,20190811T194400.000Z
TR,NRJ.POMPES_BACHE.PUISSANCE_ELEC_INST,0,65535,1,1,,0,0,2
20190811T080000.000Z,0.00800000037997961,192
20190811T080100.000Z,0.008999999612569809,192
20190811T080200.000Z,0.008999999612569809,192
LB,32734,0,T,NRJ.POMPES_BACHE.PUISSANCE_ELEC_CPT,20190811T080000.000Z,20190811T201200.000Z
TR,NRJ.POMPES_BACHE.PUISSANCE_ELEC_CPT,0,65535,1,1,,0,0,2
20190811T080000.000Z,0.6743068099021912,192
20190811T080100.000Z,0.6744459867477417,192
20190811T080200.000Z,0.6745882630348206,192
20190811T080300.000Z,0.6747232675552368,192
20190811T080400.000Z,0.6748600006103516,192
20190811T080500.000Z,0.6749916672706604,192
20190811T080600.000Z,0.6751362681388855,192
我只想匹配具有这种格式的行
20190811T080000.000Z,0.00800000037997961,192
所以我试过这个正则表达式
^([^,]*,){2}[^,]*$
并在此网站上工作:https ://regex101.com/r/iIbpgB/3
但是,当我在 Java 上实现它时,它不起作用。
Pattern pattern = Pattern.compile("^([^,]*,){2}[^,]*$");
Matcher matcher = pattern.matcher(content);
if ( matcher.find()){
System.out.println(matcher.group());
}
您可以在这里验证:https://www.codiva.io/p/e83bcde1-8528-4330-94a2-58fe80afffc0
有人有解释吗?..谢谢
繁星淼淼
白板的微信
相关分类