regex - How to describe an optional negative lookahead in regular expression? -
i appointment description of calender entries program called khal outputs using grep. output of khal looks this:
20:30-22:30 13.05.2015: manfred treffen repeat: freq=weekly;byday=we;wkst=mo 09.05. - 12.05.2015: britt besuch in example match manfred treffen , britt besuch. however, can see first appointment repeating appointment , there khal adds these information output. in case regular expression has assure every whole part starting repeat: omitted, of course if exists.
grep -op "(?<=: )(.)+(?=repeat: .+$)" gets me manfred treffen not britt besuch
however grep -op "(?<=: )(.)+(?=repeat: .+$|$)" gives me descriptions of both appointments first 1 whole "repeat:…" part included.
what seem need optional lookahead. found similar question on stackoverflow didn't understand approach (greedy match) nor possible adopt case.
Comments
Post a Comment