in reply to negated word issue

Changing your regex to

/my background error (\d+):(?!.+my3\.exe)/

seems to capture what you're after.

Here's a few tests:

$ perl -Mstrict -Mwarnings -E 'while (<>) { if (/my background error ( +\d+):(?!.+my3\.exe)/ ) { say $1 } }' blah blah my background error 1234: blah blah 1234 blah blah my background error 1234: blah blah my3.exe blah blah blah my background error 1234: blah blah my4.exe blah 1234 blah blah my background error 1234: my3.exe blah blah my background error 1234:my3.exe 1234 ^C

Note the last one with 1234:my3.exe is a match: which seems to follow the pattern you're describing. If you don't want that line either, use .* instead of .+, i.e. change (?!.+my3\.exe) to (?!.*my3\.exe).

UPDATE

I noticed you wanted to capture the text after the error number as well as that number. The solution above doesn't do that. The following regex will:

/my background error (\d+): ((?!.*my3\.exe).+)/

Retested:

$ perl -Mstrict -Mwarnings -E 'while (<>) { if (/my background error ( +\d+): ((?!.*my3\.exe).+)/ ) { say qq{$1 = \"$2\"} } else { say q{NO M +ATCH} } }' blah blah my background error 1234: blah blah 1234 = "blah blah" blah blah my background error 1234: blah blah my3.exe blah NO MATCH blah blah my background error 1234: blah blah my4.exe blah 1234 = "blah blah my4.exe blah" blah blah my background error 1234: my3.exe NO MATCH blah blah my background error 1234:my3.exe NO MATCH blah blah my background error 1234: my4.exe 1234 = "my4.exe" ^C

-- Ken

Replies are listed 'Best First'.
Re^2: negated word issue
by Anonymous Monk on Mar 01, 2012 at 17:25 UTC
    Thanks. I was still trying to figure this out when you posted the update.