in reply to Two Eclectic split()s

use Data::Dumper; my $string = '"I think" this fits "the \\"requirements presented\\" th +en" again \\"I could "be wrong"'; print Dumper [split /\s+(?=(?:(?:(?:[^"\\]|\\")*"){2})*(?:\\"|[^"])*$) +/, $string];
On a side note Method 1 returns the following (on AS 5.8):
"I think" this fits 1 1 again \"I could "be wrong"
and Method 2: returns:
I think this 1 1 requirements presented\ then again \ I could be wrong
update:Looks a little nicer if I don't compensate for escaped quotes:
split /\s+(?=(?:(?:[^"]*"){2})*[^"]*$)/,$string

-enlil

Replies are listed 'Best First'.
Re: Re: Two Eclectic split()s (another one maybe?)
by japhy (Canon) on May 21, 2003 at 14:18 UTC
    Hehe, then there was some split/regex bug that was fixed. The weird 1's are related to the flip-flop variable I've got in my code. Oh well.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;