in reply to Re: Regular Expression
in thread Regular Expression
Heck, if you're going to do that, you might as well get it all:
#!/usr/bin/perl -w use strict; $_ = '%MYBOARD{project1|nameofproject1 remarks="Good,Verygood,bext,exc +ellent" grade="7" teacher="Priyanka"}%'; my %map; $map{$1} = $2 while s/^.*? (\S+)="([^"]+)"//g; print "$_: $map{$_}\n" for keys %map;
Output:
grade: 7 teacher: Priyanka remarks: Good,Verygood,bext,excellent
The above can also be spelled
print map {"$1: $2\n" if /(\S+)="([^"]+)"/} split;
but I suspect that this would be a bit much for the OP... :)
-- Education is not the filling of a pail, but the lighting of a fire. -- W. B. Yeats
|
|---|