Skip to main content

Best Answers

10435 Posts
How to return specific lines from log file based on regex?

I want to extract specific lines from a log file, based on an regex. However, instead of getting a whole line as match returned, or even better a list of matches, I am getting <null> returned. What I want from the log file are all the warnings. I used an AttributManager and set the Attribute Value for the new attribute to @SubstringRegularExpression(@Value(_log_attr),^.*\|WARN\s{2}\|.*$,0,0,5)The last parameter is already misleading, since I usually do not have an idea of how many warnings there might be in an arbitrary log file, but for the sake of my test it would work.I would expect that the first match (out of 5) is returned. Ideally, a startIdx of -1 would give me the last of the five matches, but that doesn't work either. For the fun of it I was testing the same expression within a StringSearcher and here, there is a match. However, the attribute containing the matched result, who is supposed to return "the portion of the original search string that matched the regular expr

Badge Winners

Show all badges

Community Stats

31,951
Posts
121,336
Replies
39,562
Members

Latest FME