Keep It Simple, Stupid | |
PerlMonks |
Regular Expression - print out certain sections of line based on the contentby jas999 (Initiate) |
on Jan 02, 2009 at 14:36 UTC ( [id://733761]=perlquestion: print w/replies, xml ) | Need Help?? |
jas999 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, Im looking for a way to print out certain sections of line based on the content.
For example, I want to print out the ENV (just whats in the brackets) if the STATUS is Not Running. Also, I want to print out whats in FIRST and in PHONE.
var1 = "ENV(ABCD1234) STATUS(Running)" var2 = "ENV(IJK1234) STATUS(Not Running)" var3 = "PRINT NAME FIRST(ABCD) SECOND(EFGH) ADDRESS('') PHONE(12345678)" var4 = "PRINT NAME FIRST() SECOND(WXYD) ADDRESS('') PHONE(87654321)" What's the best way to do this? I have tried splitting and substituting but am not succeeding. Do I need to have a specific regular expression? Any ideas?
Back to
Seekers of Perl Wisdom
|
|