Link to home
Start Free TrialLog in
Avatar of ashsysad
ashsysadFlag for United States of America

asked on

Need help to correct my RegEx

Hello,

Please help me to correct my RegEx.  Let me give the pattern of file that is used for parsing.

 Nov  4 15:39:42 old-dns-1 named[1579]: client 10.123.62.126#36807: query: 126.62.113.10.in-addr.arpa IN PTR +
 Nov  4 15:39:43 old-dns-1 named[1579]: client 10.123.63.60#36992: query: 63.63.113.10.in-addr.arpa IN PTR +
 Nov  4 15:39:47 old-dns-1 named[1579]: client 10.123.62.126#33281: query: 126.62.113.10.in-addr.arpa IN PTR +
  Nov  4 15:39:50 old-dns-1 named[1579]: client 10.123.63.60#36992: query: 62.63.113.10.in-addr.arpa IN PTR +
 Nov  4 15:39:50 old-dns-1 named[1579]: client 10.123.63.65#36992: query: 63.63.113.10.in-addr.arpa IN PTR +

Open in new window


Expected output:
10.123.62.126
10.123.63.60
10.123.62.126
10.123.63.60
10.123.63.65

RegEx used (in if statement):

if($_ =~ m/^\w+\s+\d+\s\d\d:\d\d:\d\d\s\S+\snamed[1579]:\sclient\s(\d+:\d+:\d+:\d+)#\d+:\squery/)
            {
              printf "%-16s\n",$1;
              $cnt++;
            }

For some reason, I'm not getting the expected output. Could you please correct it and let me know ?  Thanks.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ashsysad

ASKER

Thanks a lot Ozo !! I realized my mistake now :)