Reputation: 1797
I have a log file which I am trying to scan for patterns and count the number of times certain patterns are seen. The log looks like this
11298 [out] [worker:83] data has been rebuilt.
11299 [out] [worker:83] END Building data for foo
11299 [out] [worker:83] END Building data for bar
11300 [out] [worker:83] BEGIN Building data for baz
11301 [err] [worker:83] Putin bombed Syria
I am interested in all the lines starting with [out] and containing END, BEGIN or rebuilt (need to count them separately). So I thought the following regex
(out.*END)*
would match the patch the pattern out] anything here END
multiple times, but it only gives me the first instance of out
in my file and stops. Can someone point me in the right direction ?
I am doing this in MATLAB with the syntax regexp(txt,expr,'start')
Upvotes: 1
Views: 280
Reputation: 1997
Here's a doc: http://www.mathworks.com/help/matlab/ref/regexp.html
regexp
by default returns all matches.
Try playing with options and outkeys (passed as 3rd argument). It looks like this one could help: 'dotexceptnewline'
- your regex is greedy and probably matches whole thing (from first out
to last END
).
Try using outkey 'match'
instead of 'start'
.
Also check if your results aren't truncated by mistake.
Upvotes: 2