0
https://github.com/thekrakken/java-grok爲什麼java-grok在字符串不匹配時返回最後一次成功匹配?
我正在使用Grok API for Java。代碼如下:
Grok grok = Grok.EMPTY;
// add a pattern to grok
grok.addPatternFromFile("pat.txt");
// compile and add semantic
grok.compile("%{NUMBER:hits} %{USER:word}");
String str = "234 wdfd\n";
Match m = grok.match(str);
m.captures();
// Print
System.out.println(m.toJson());
grok = Grok.EMPTY;
str = "ssdfsdf\n";
Match m2 = grok.match(str);
m2.captures();
System.out.println(m2.toJson());
的程序的輸出是:
{"hits":234,"word":"wdfd"}
{"hits":234,"word":"wdfd"}
我清空神交例如,我使用單獨的「M2」匹配變量,但仍然程序返回上次成功匹配而不是NULL或者可以通知我匹配失敗的錯誤。我怎麼知道比賽失敗的時候?
你確定你重新編譯你的代碼? – chrylis
是的,看起來當沒有比賽的時候,最後一場比賽就交付了。嘗試調試到源代碼。 **聯繫他們。** –