Magnolia25 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to build a regular expression for below files.
HIGH-LEVEL Status file for process (can be in below formats)
server_load_<ipaddress>.<ipaddress>.SKIP server_load_<ipaddress>.xyz_<ipaddress>.SKIP Example. server_load_IP100.69.82.21.IP100.69.82.81.SKIP server_load_IP100.69.82.21.ny_IP100.69.82.81.SKIP
Detailed Status file for process (can be in below formats)
server_load_<ipaddress>.<ipaddress>.xyx_ABC-2.SKIP server_load_<ipaddress>.ny_<ipaddress>.ABC_load.SKIP Example server_load_IP100.69.82.21.IP100.69.82.81.ny_AMER-2.SKIP server_load_IP100.69.82.21.ny_IP100.69.82.81.AMER_load.SKIP
My regular expression SHOULD NOT match any name from HIGH-LEVEL Status file for process. only that will work for Detailed Status file for process.
Tried using Look-ahead and look-behind concepts, but not able to get my best.
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { if (/^(?<!server_load_IP100.69.82.21\s).*.SKIP/) {print "Good Match "; +} else {"Bad Match ";} print; } __DATA__ server_load_IP100.69.82.21.IP100.69.82.81.SKIP server_load_IP100.69.82.21.IP100.69.82.81.ny_AMER-2.SKIP
Output =============== Good Match server_load_IP100.69.82.21.IP100.69.82.81.SKIP ==> Ideall +y this is HIGH-LEVEL Status file for process should be "Bad Match " Good Match server_load_IP100.69.82.21.IP100.69.82.81.ny_AMER-2.SKIP
Any thoughts or guidance please. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deriving File name convention with Look-ahead and look-behind assertion
by Eily (Monsignor) on Oct 19, 2016 at 14:39 UTC | |
|
Re: Deriving File name convention with Look-ahead and look-behind assertion
by Laurent_R (Canon) on Oct 19, 2016 at 17:10 UTC |