[tpm] I wish I was better at regex's

Fulko Hew fulko.hew at gmail.com
Wed Mar 9 11:25:09 PST 2011


On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer <sfryer at sourcery.ca> wrote:

> my $strip = qr{;[^\;]+$};
> while (<DATA>) {
>    chomp;
>     my ($key, $val) = split /=/;
>    my ($quote) = ($val =~ m{^(["'])}g);
>    if ($quote) {
>        ($val) = ($val =~ m{^($quote[^\b]+($quote))}g);
>    }
>    else {
>        $val =~ s/$strip//;
>    }
>    print $key, '=', $val, "\n";
> }
>

Closer, but it still assumes the key=value concept,
the goal was  'any trailing comment' (not quoted) ie. regardless of the
syntax before it
as in the following additional test case:

title ;comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20110309/34c0fdbd/attachment.html>


More information about the toronto-pm mailing list