Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to slice complicated string into an array

by Anonymous Monk
on Feb 29, 2016 at 08:40 UTC ( [id://1156423]=note: print w/replies, xml ) Need Help??


in reply to How to slice complicated string into an array

Buy the Perl Cookbook which has a neat solution:
my @a; my $s = '"word1",word2,"word3,word4"'; push(@a, $+) while $s =~ m {"([^\"\\]*(?:\\.[^\"\\]*)*)",? | ([^,]+),? | ,}gx; print "|$_|\n" for (@a);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1156423]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-19 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found