Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Regular Expression - print out certain sections of line based on the content

by gasho (Beadle)
on Jan 02, 2009 at 15:27 UTC ( [id://733777]=note: print w/replies, xml ) Need Help??


in reply to Re: Regular Expression - print out certain sections of line based on the content
in thread Regular Expression - print out certain sections of line based on the content

Slightly modified and tested
@strings = ( "ENV(ABCD1234) STATUS(Running)", "ENV(IJK1234) STATUS(Not Running)", "PRINT NAME FIRST(ABCD) SECOND(EFGH) ADDRESS('') PHONE(12345678)", "PRINT NAME FIRST() SECOND(WXYD) ADDRESS('') PHONE(87654321)" ); foreach $line (@strings){ if ($line=~/ENV\((.*?)\) STATUS\(Not Running\)/){ print "$1\n"; } if ($line=~/PRINT NAME FIRST\((.*?)\) SECOND\((.*?)\) ADDRESS\ +((.*?)\) PHONE\((.*?)\)/){ print "$1 $4\n"; } }
(: Life is short enjoy it :)
  • Comment on Re^2: Regular Expression - print out certain sections of line based on the content
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://733777]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-23 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found