can any one explain to me why this doesn't seem to work:
push @elements, $2 while
/\G\s*(["'])([^\\\1]*(?:\\.[^\\\1]*)*)\1/gc or
/\G(\s*)(\S+)/gc; # k i know that's kinda kloogy, but I'm
experimenting.
-----Original Message-----
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2001 8:38 AM
To: Ondrej Par
Cc: Accountant Bob; "Randal L. Schwartz" <[EMAIL PROTECTED]> Peter
Cornelius; [EMAIL PROTECTED]
Subject: Re: splitting strings with quoted white space
On Jun 7, Ondrej Par said:
>On Wednesday 06 June 2001 22:59, Jeff 'japhy' Pinyan wrote:
>> On Jun 6, Accountant Bob said:
>> >How about this: (the same but "unrolled")
>> >
>> >my @elements;
>> >push @elements, $1 while
>> > /\G\s*"([^\\"]*(?:\\["\\][^\\"]*)*)"/gc or
>
>I think that
> /\G\s*"((?:(?:\\.)|[^\\])*?)"/gc
>
>is shorter and also matches all \X sequences (the trick is that \\. is
longer
>than [^\\]
The formula for unrolling the loop is
NORMAL* (SPECIAL NORMAL*)*
Here, NORMAL is /[^\\"]/, and SPECIAL is /\\./ -- at least, I'm using \\.,
since I want any backslash to pass through ok.
Thus, our regex is:
push @elements, $1 while
/\G\s*"([^\\"]*(?:\\.[^\\"]*)*)"/gc or
/\G\s*'([^\\']*(?:\\.[^\\']*)*)'/gc or
/\G\s*(\S+)/gc;
Of course, that last regex can changed to your whims...
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **