0

We're using HP SiteScope system at work to monitor logs and get alerts when a special string or combination of strings is caught.

There is one field where the regular expression that catches the strings is placed, however I want to exclude some of the results which we catch with the reg exp. For example:

grep -E '(GOOD_STRING1|GOOD_STRING2)' | grep -v BAD_STRING

needs to be transformed into a single reg exp. Something like this:

grep -E '(GOOD_STRING1|GOOD_STRING2)!BAD_STRING)'

Is that possible?

1 Answer 1

1

You can do this with Perl regular expressions:

$ echo 'GOOD_STRING1
> GOOD_STRING1BAD_STRING' | grep -P '(GOOD_STRING1|GOOD_STRING2)(?!BAD_STRING)'
GOOD_STRING1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .