[tpm] I wish I was better at regex's
Rob Janes
janes.rob at gmail.com
Wed Mar 9 11:11:30 PST 2011
except
key="value1;value2" comes out as key="value1
and
"key"="value1;value2" comes out as "key"="value1
this is the case where there is no comment, but there is a ; inside
the value or key.
i really don't think there's any short way to do this, unless you
don't care about stuff like this.
-rob
On Wed, Mar 9, 2011 at 1:48 PM, Shaun Fryer <sfryer at sourcery.ca> wrote:
> 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
>>
>>
> _______________________________________________
> 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