Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Regex to match "this=that" multiple times

by smokemachine (Hermit)
on Jul 16, 2008 at 19:18 UTC ( [id://698118] : note . print w/replies, xml ) Need Help??


in reply to Regex to match "this=that" multiple times

> perl -MData::Dumper -e '%hash = "lala=lele lili=lolo lulu = lala\nae +iou =abcde" =~ /(\S+)\s*=\s*(\S+)/g; print Dumper \%hash' $VAR1 = { 'lulu' => 'lala', 'lili' => 'lolo', 'lala' => 'lele', 'aeiou' => 'abcde' };
or
> perl -MData::Dumper -e '@array = "lala=lele lili=lolo lulu = lala\na +eiou =abcde" =~ /\S+\s*=\s*(\S+)/g; print Dumper \@array' $VAR1 = [ 'lele', 'lolo', 'lala', 'abcde' ];