我正在使用此REGEX选择匹配时需要忽略的部分(2017-03-06T17:32:33.618):\d{4}(-)\d{2}(-)\d{2}T\d{2}:\d{2}:\d{2}.\d{3}
。
我使用了所有可能的组合来获得"匹配除了以下正则表达式之外的所有内容"结果我需要。但我似乎无法让它发挥作用。
String test =
" drawId, MIN(draw.draw_date_time) nearestFeatureDraw FROM draw WHERE draw.draw_date_time > " +
"'2017-03-06T17:32:33.618' GROUP BY draw.lottery_info_id ) nearestDraw on nearestDraw.lotto_id = li.id " +
"WHERE 1 = 1 AND li.id = 3 AND lower(li.name) LIKE '%blablabla%' " +
"ORDER BY jackPot DESC ORDER BY nearestFeatureDraw DESC ";
boolean pleaseBeTrue = test.matches("Input your Regex here please, and return True");
System.out.println(pleaseBeTrue);
我很感谢你的帮助,让正确的Regex匹配除了确切的DateTime之外的所有内容。
答案 0 :(得分:0)
创建一个不包含时间戳的临时变量temp
,然后在其上调用matches()
方法:
String temp = test.replaceAll("\\d{4}(-)\\d{2}(-)\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}", "");
boolean pleaseBeTrue = temp.matches("Input your Regex here please, and return True");