|
From: Kevin A. <al...@se...> - 2001-08-28 21:32:02
|
> From: Magnus Lie Hetland
>
> By the way, I found this Perl snippet <shudder>
>
> sub parse_csv {
> my $text = shift; # record containing comma-separated values
> my @new = ();
> push(@new, $+) while $text =~ m{
> # the first part groups the phrase inside the quotes.
> # see explanation of this pattern in MRE
> "([^\"\\]*(?:\\.[^\"\\]*)*)",?
> | ([^,]+),?
> | ,
> }gx;
> push(@new, undef) if substr($text, -1,1) eq ',';
> return @new; # list of values that were comma-separated
> }
>
> Makes me remember why I use Python <wink>
Which reminds me of a favorite Jamie Zawinski quote:
Some people, when confronted with a problem, think "I know, I'll use regular
expressions." Now they have two problems.
--Jamie Zawinski, in comp.lang.emacs
I saw this while reading http://diveintopython.org/dialect_re.html
ka
|