in reply to csv'ish string with parens that include commas
Use Regexp::Common::list, something like this (presuming your strings and all word characters):
returns:use Regexp::Common 'list'; my $re = qr{ \w+ # word characters (word or function name) (?:\($RE{list}{-pat=>'\w+'}\))? # (optional parameters) }x; my $x = 'joe,sam,x(monkey,lemur)'; my @x = ($x =~ m{$re}g); print join("\n", @x);
joe sam x(monkey,lemur)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: csv'ish string with parens that include commas
by ascetic (Novice) on Dec 05, 2010 at 04:07 UTC | |
by james2vegas (Chaplain) on Dec 05, 2010 at 04:11 UTC |
In Section
Seekers of Perl Wisdom