[tpm] I wish I was better at regex's
Fulko Hew
fulko.hew at gmail.com
Wed Mar 9 08:15:30 PST 2011
Today's regex problem is a standard problem, that has standard answers,
I just don't know them, and I haven't found them...
"Strip comments from lines while obeying quoted strings".
I've got a fellow who's dealing with 'registry files', but needs to
strip comments off of the end of the lines (I.e. anything after a semicolon)
but preserve semicolons (and text) if found within a quoted string.
I know there are hard ways to do it, but there's got to be a module
to handle it for me.
Here are some example strings:
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
Suggestions?
Fulko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20110309/10e27082/attachment.html>
More information about the toronto-pm
mailing list