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

Shaun Fryer sfryer at sourcery.ca
Wed Mar 9 10:48:39 PST 2011


my $strip = qr{;[^\;]+$};
while (<DATA>) {
    chomp;
    $_ =~ s/$strip//;
    print $_, "\n";
}

__DATA__
key="value"
key=value
key="value1;value2"
key="value1;value2"     ; comment
key='value1;value2'     ; comment
"key"="value1"
"key"="value1"          ; comment
"key"="value1;value2"
"key"="value1;value2"   ; comment
"key"="val\"ue1;value2"
"key"="val\"ue1;value2" ; comment
"key"='val\'ue1;value2' ; comment
"key"='val\"ue1;value2' ; comment

--
Shaun Fryer
cell: 1-647-709-6509
voip: 1-647-723-2729




On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew <fulko.hew at gmail.com> wrote:
>
> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes <janes.rob at gmail.com> wrote:
>>
>> here's one that dequotes the key and value ...
>
> Thanks for the ideas, but..
> the issue isn't with extracting the keys and the values (and dequoting
> them),
> the task was only to strip trailing comments (while obeying quoted strings)
>
>
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>


More information about the toronto-pm mailing list