in reply to String parsing
Hard to do robustly with a regex
while(<DATA>) { chomp; my ( @bits, $rest ); ( $bits[0], $rest ) = split ':', $_, 2; $bits[0] =~ tr/()//d; push @bits, ($rest =~ m!\(([^)]+)!g) if $rest; print "@bits\n"; } __DATA__ OFF SUCCESS: (abc) ERROR(1): disk number (27) crashed at (11:03) WARNING(1): system is rebooting
Which gives you
OFF SUCCESS abc ERROR1 27 11:03 WARNING1
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: String parsing
by BrowserUk (Patriarch) on Jan 05, 2004 at 12:42 UTC |