in reply to Regex negation (or golf)
use strict; use warnings; use Data::Dumper; my $rxFlds = qr {(?x) " ([^"]*) " ([^,]*) (?:,|\z) }; my $resp = q{"F059"3,"Invalid blech"99,"","This, that"33,""77,}; my @flds; while ( $resp =~ m{$rxFlds}g ) { push @flds, [$1, $2]; } print Data::Dumper->Dumpxs([\@flds], [qw{*flds}])
Here's the output
@flds = ( [ 'F059', '3' ], [ 'Invalid blech', '99' ], [ '', '' ], [ 'This, that', '33' ], [ '', '77' ] );
I hope this is of use.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex negation (or golf)
by bradcathey (Prior) on Feb 20, 2007 at 15:35 UTC | |
by johngg (Canon) on Feb 20, 2007 at 15:47 UTC |