I am trying to parse a log file that looks like this:
%%%% 09-May-2009 04:10:29
% Starting foo
this is stuff
to ignore
%%%% 09-May-2009 04:10:50
% Starting bar
more stuff
to ignore
%%%% 09-May-2009 04:11:29
...
This excerpt contains two time periods that I would like to extract: from the first separator to the second and from the second to the third. I would like to use regex to extract the start and stop times for each of these intervals. This basically works:
p = '%{4} (?<start>.*?)\n% Starting (?<name>.*?)\n.*?%{4} (?<stop>.*?)\n';
times = regexp(c,p,'names');
Return:
times =
1x16 struct array with fields:
start
name
stop
The problem is that it only captures every other period, since the second delimiter is consumed as part of the first match.
(lookahead, lookbehind) . , MATLAB, , . , , ( ).
?
P.S. , , -, .
: , . , MATLAB.