in reply to Regular Expression

Get Both: (Linux run):
>: perl -e 'print qq|$_\n| for q~%MYBOARD{project1|nameofproject1 rema +rks="Good,Verygood,bext,excellent" grade="7" teacher="Priyanka"}%~=~m +/grade="([^"]+).+teacher="([^"]+)/' 7 Priyanka

     Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

Replies are listed 'Best First'.
Re^2: Regular Expression
by oko1 (Deacon) on Feb 18, 2011 at 03:11 UTC

    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