in reply to Runtime Regexp Generation
Combine them:
while (chomp($_ = <TOPARSE>)) { next unless /\d+\s+(\d+)\s+(1\.2\.3\.4)\s+->\s+(4\.3\.2\.1)\s+(?!TC +P)([^\s]+)\s+(3456)\s+>\s+(113)/; print; }
That way, you get the best of both worlds. You just do a negative lookahead (?!) AND a protocol gulper (like ([^\s]+), and you can still search for all your other strings that you want to search for.
This will match on source 1.2.3.4 and destination of 4.3.2.1, but will make sure it is not a TCP packet. Best of both worlds...
Update: Per chromatic's and tye's recommendations, my proposed code would look like this:
while (<TOPARSE>) { next unless /^\d+\s+(\d+)\s+(1\.2\.3\.4)\s+->\s+(4\.3\.2\.1)\s+(?!T +CP\s)([^\s]+)\s+(3456)\s+>\s+(113)/; print; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Runtime Regexp Generation
by chromatic (Archbishop) on Apr 14, 2003 at 16:51 UTC | |
|
Re^2: Runtime Regexp Generation (anchor)
by tye (Sage) on Apr 14, 2003 at 17:49 UTC |