Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Help with regex for complicated key=value string

by kvale (Monsignor)
on Oct 29, 2008 at 18:49 UTC ( #720293=note: print w/replies, xml ) Need Help??


in reply to Help with regex for complicated key=value string

I would split on everything that is not a bare comma (untested):
my $q_str = qr("[^"]*"); # quoted string my $unq_nc_str = qr([^",]+); # string with no quotes or commas my $esc_com = qr(\\\\,); # escaped comma my @bits = grep {$_ ne ','} split /((?:$q_str|$unq_nc_str|$esc_com)+)/, $line;
By grouping the split regex, we get split bits as well as bare commas. Then we filter bare commas. This assumes that quotes are not nested.

-Mark

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://720293]
help
Chatterbox?
shmem bows. Thank you
[marto]: slowclap.gif
[marto]: animated gif in question...
[1nickt]: Interesting article on the Coming Software Apocaplyse that I found while following one of eyepopslikeamosqui to's posts. Posits that no one can guarantee the quality of, or even understand, the 100 million lines of code in a mo
[holli]: you know, monk days are fun and all. but too many of them are bad for your health
[1nickt]: ...modern car. Suggests using TLA+ or other software modeling language to autogenerate code.
1nickt is not sure more and more layers separating the programmer from the program is the right way to go...
[holli]: happy one, shmem ;)
[1nickt]: I had an interview couople of weeks ago, heard from a principal engineer that a friend of his who works at The Google told him that the self-teaching software that determines the dynamic pricing for their adverts...
[1nickt]: ... has become so complex that there is no one at the Goole who knows what it does.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2017-11-21 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (301 votes). Check out past polls.

    Notices?