Is there any quick way of parsing a string like: This,Is,A,String,\,,With,A,Comma
Into a list ("This", "Is", "A", "String", ",", "With, "A", "Comma")
Basically, how can I split it by commas, except when it is escaped.
How about:
my @fields = split m/(?<!\\),/, 'This,Is,A,String,\\,,With,A,Comma'; print join('~', @fields), "\n";
That's a negative lookbehind assertion in the regex I fed split().
If you made the original string format, you might consider using the CSV file format instead. Then you can even use modules to do all the tricky stuff.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>