http://qs1969.pair.com?node_id=733777


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 :)