[tpm] I wish I was better at regex's
J. Bobby Lopez
jbl at jbldata.com
Wed Mar 9 14:03:02 PST 2011
Then I suppose a rephrasing the question would be beneficial. Instead of:
"Strip comments from lines while obeying quoted strings"
"Rip key/value pairs from line, and disregard comments".
Which would put the focus on the key/val pairs (with an opportunity to
normalize them; convert them all to quoted values, for example), instead of
focusing on stripping the comments away.
On Wed, Mar 9, 2011 at 4:43 PM, Uri Guttman <uri at stemsystems.com> wrote:
> >>>>> "JBL" == J Bobby Lopez <jbl at jbldata.com> writes:
> JBL> Agreed, but in the event that you don't have a strict format for
> JBL> comments and key/value pairs (quotes/no quotes; comments with
> JBL> special characters/without), then you're still looking for the
> JBL> last instance of ';' outside of last (possible) quote, no?
> if you DON'T have a strict format, how can it be parsed and used by any
> program? you have to assume or know the rules. this is a config file
> that is already being parsed and used by some program. the OP wants to
> modify it with perl regexes which is the wrong solution. since it has a
> specification of some sort, it can be parsed and left to right parsing
> is the way to go.
> Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com--
> ----- Perl Code Review , Architecture, Development, Training, Support
> --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com---------
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the toronto-pm