Reputation: 41460
I am trying to get some data for Splunk.
From this:
this my line - Fine (R/S)
more date - I like this (not)
date - output (yes)
I like to get all data from -
to the end of line, but not the data in parentheses if it contains not
or yes
, so data in group1
should be:
Fine (R/S)
I like this
output
I have tried some like this:
- (.+) (?!(not|yes))
But this gives:
Fine
I like this
output
Or This:
- (.+)(?!not)
Gives:
Fine (R/S)
I like this (not)
output (yes)
Upvotes: 3
Views: 1909
Reputation: 174874
You may try this,
- ((?:(?!\((?:not|yes)\)).)*)(?=\s|$)
or
- (.*?)(?=\s+\((?:not|yes)\)|$)
This would capture all the chars until a space(yes)
or space(no)
or end of the line is reached.
Upvotes: 3