- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- strange requirement & my regX is unable to match i...
Operating System - HP-UX
1752584
Members
4138
Online
108788
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
09-08-2009 09:26 PM
09-08-2009 09:26 PM
strange requirement & my regX is unable to match it
Hi,
I have a very strange below requirement and my regX is unable to match it.
Below is my script:
++++++++++++++++++++++++++++++++++
$_ = "Probable Cause :
Probable Cause 1, ProbablCause 2, Probable Cause 3
Probable Cause 1, Probable Cause 2, Probable Cause 3
Recommended Action :
Not Available
Replaceable :
Part Manufacturer : Not Available
Spare Part No. : Not Available
Additional Info : Not Applicable
";
my $match = "Probable Cause";
if (/$match\s+:([a-zA-Z0-9,\s]*):/m) {
print ("[$match] found\n");
print "[$1]\n";
} else {
print ("$match not found!\n");
}
+++++++++++++++++++++++++++++++++++++++++++
my requirement is to fetch values of certain attributes (e.g Spare Part No, Probable Cause etc) catch is
1. values can be in multiple lines having all kinds of chars except ":" some times not having anything also (including junk chars - bÿ5)
2. I will not know next attribute of my search (e.g if I am searching for Spare Part No I will not know Additional Info.)
All I know is I have multiple attributes each attributes ends with "\s:\s"
this above regX will not work for all conditions - can some one help me please please
- Thanks and Regards,
Mahesh S Rao
I have a very strange below requirement and my regX is unable to match it.
Below is my script:
++++++++++++++++++++++++++++++++++
$_ = "Probable Cause :
Probable Cause 1, ProbablCause 2, Probable Cause 3
Probable Cause 1, Probable Cause 2, Probable Cause 3
Recommended Action :
Not Available
Replaceable :
Part Manufacturer : Not Available
Spare Part No. : Not Available
Additional Info : Not Applicable
";
my $match = "Probable Cause";
if (/$match\s+:([a-zA-Z0-9,\s]*):/m) {
print ("[$match] found\n");
print "[$1]\n";
} else {
print ("$match not found!\n");
}
+++++++++++++++++++++++++++++++++++++++++++
my requirement is to fetch values of certain attributes (e.g Spare Part No, Probable Cause etc) catch is
1. values can be in multiple lines having all kinds of chars except ":" some times not having anything also (including junk chars - bÿ5)
2. I will not know next attribute of my search (e.g if I am searching for Spare Part No I will not know Additional Info.)
All I know is I have multiple attributes each attributes ends with "\s:\s"
this above regX will not work for all conditions - can some one help me please please
- Thanks and Regards,
Mahesh S Rao
Little progress everyday... ...Adds upto big results
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2009 01:18 AM
09-09-2009 01:18 AM
Re: strange requirement & my regX is unable to match it
I managed to get with below regX thanks.
if (/$match\s+:([^:]*)/m) {
my $data;
print ("[$match] found\n");
$data = trim ($1);
print "[$data]\n";
} else {
print ("$match not found!\n");
}
trim function removes spaces, '\n' and last line if scalar ($1) is greater than 1 :)
I got what I was looking for it.
if (/$match\s+:([^:]*)/m) {
my $data;
print ("[$match] found\n");
$data = trim ($1);
print "[$data]\n";
} else {
print ("$match not found!\n");
}
trim function removes spaces, '\n' and last line if scalar ($1) is greater than 1 :)
I got what I was looking for it.
Little progress everyday... ...Adds upto big results
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP