How to get negative result in regex to accept more words

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 the line, but not the data in parentheses if they contain not

or yes

, so the data in group1

should be:

Fine (R/S)
I like this
output

      

I've tried several of these:

- (.+) (?!(not|yes))

      

But this gives:

Fine
I like this
output

      

Or that:

- (.+)(?!not)

      

gives:

Fine (R/S)
I like this (not)
output (yes)

      

+3


source to share


1 answer


You can try this,

- ((?:(?!\((?:not|yes)\)).)*)(?=\s|$)

      

DEMO

or



- (.*?)(?=\s+\((?:not|yes)\)|$)

      

This will capture all characters until space(yes)

either space(no)

or the end of the line is reached .

DEMO

+3


source







All Articles