in reply to Re: Zero-width assertions fail with split
in thread Zero-width assertions fail with split

That makes sense and, as noted, the results aren't entirely suprising, though I confess I struggled with it. Is there some simple way of getting the split behavior to do what I want?

Cheers,
Ovid

New address of my CGI Course.

  • Comment on Re^2: Zero-width assertions fail with split

Replies are listed 'Best First'.
Re^3: Zero-width assertions fail with split
by hv (Prior) on Sep 19, 2005 at 12:00 UTC

    You want "not both preceded and followed by TOKEN", which is equivalent to "either not preceded by TOKEN, or not followed by TOKEN", and that we can do:

    my $split = qr/ (?<!$token) , | , (?!$token) /x;

    Hugo

Re^3: Zero-width assertions fail with split
by gargle (Chaplain) on Sep 19, 2005 at 06:16 UTC

    Hi,

    It may be silly, but, doesn't this do what you want?

    perl -e '$a = "1,2,---0---,3,4";@f=split ",",$a;map { print $_."\n"} @f'
    --
    if ( 1 ) { $postman->ring() for (1..2); }