- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Regarding Regular Expression in Perl
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2009 10:10 PM
тАО06-03-2009 10:10 PM
Regarding Regular Expression in Perl
Trying to write a RE in perl for the following patterns,
"OV_Node_Down, Status Alarms: Node Down Root Cause: DEL-DAV Lo0"
"OV_Node_Down, Status Alarms: Node Down Cause: TIR-VAK Lo0"
"OV_Node_Down, Status Alarms: Node Down Problem Cause: BLR-VHS Fa0/0"
"OV_Node_Down, Status Alarms: Node Down interface Cause: VIZ-REG Se0/0"
"OV_Node_Down, Status Alarms: Node Down Root Cause: KOL-RGH BR1/0:1"
"OV_Node_Down, Status Alarms: Node Down Root Cause: BHU-TAN Se0"
"OV_Node_Down, Status Alarms: Node Down Root Cause: KOL-DUR Fa0/0"
Now my conditions is,
Need to check for "Node Down" and it should not contain Lo0, Fa0/0 at the end of the string
Tried the following RE, but it is not working for all strings.
/^.*Node Down.*(^Lo0)|(^Fa0/0)$/
Thanks in advance,
Regards,
Raghu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2009 02:59 AM
тАО06-04-2009 02:59 AM
Re: Regarding Regular Expression in Perl
...
}
If you insist on a single re
m{Node_Down.*$(?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2009 03:48 AM
тАО06-04-2009 03:48 AM
Re: Regarding Regular Expression in Perl
Admittedly he did not write that, but his trial solution suggests it.
The ", " is not a magical new operator is it?
The "?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2009 03:56 AM
тАО06-04-2009 03:56 AM
Re: Regarding Regular Expression in Perl
!m{Lo0$|Fa0/0$}
or
!m{(Lo0|Fa0/0)$}
If you want to see a line which has an "Lo0", but does not end in it. Like:
" Node Down Root Cause: DEL-DAV Lo0 blah"
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2009 07:12 AM
тАО06-04-2009 07:12 AM
Re: Regarding Regular Expression in Perl
The zeero-width negative-look-behind only works if both patters are of equal length.
So, the correct solution would then be
if (m{Node_Down} && !m{(?:Lo0|Fa0/0)$}) {
...
}
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2009 07:13 AM
тАО06-04-2009 07:13 AM
Re: Regarding Regular Expression in Perl
The assigned points suggests that the suggested solutions did not provide an answer what you were looking for.
Care to articulate why not?
Are the double quotes part of the actual data lines? I assumed in my olution they were there for illustrating the input data. Easy enough to accommodate for those, if need be.
For better help you may want to attach a (short) simple TEXT file with actual data lines first, and then a section highlighting the desired, and undesired matches.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2009 09:47 PM
тАО06-04-2009 09:47 PM
Re: Regarding Regular Expression in Perl
first of all thanks a lot for your lightning response and apologies for not giving the requirements clearly.
I was looking for a sigle RE which will match a message containg Node Down" and not conating "Fa0/0 or Lo0".
The catch with the solution
m{Node Down.*\s[^LF][^oa]\d\S*$}
was it is not accepting Lxx for Example:La1, which was supposed match.
in anycase your solution helped me to arrive at the required RE
^.*Node Down.*:\s.*\s(?!Lo0)(?!Fa0\/0).{3,}$
thanks again for you assistance.
Best Regards,
Raghu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-05-2009 06:22 AM
тАО06-05-2009 06:22 AM
Re: Regarding Regular Expression in Perl
Will match a character other than L or F
Followed by a character other than o or a
followed by a digit
followed by any number of non-whitespace
followed by the end of the string (option new-line allowed)
This will obviously match too much. Way too much
/^.*Node Down.*(^Lo0)|(^Fa0/0)$/
is wrong that does never match, as the syntax is not legal
It would be almost impossible to create what you want in a *legible* single regular expression.
sticking to a combined version is so much safer and easier to maintain
m{Node Down} && !m{(?: Lo0 | Fa0/0 )$}x
is IMHO the only way to go if you want to understand what you did 3 months from now
$ perldoc perlre
Will give you lots of learning stuff
Enjoy, Have FUN! H.Merijn