in reply to split on unescaped delimiters

Assuming backslashes themselves could be escaped, you want to split on colons which are preceeded by an even amount of backslashes. You can't do look behind in this case, because you can't do variable length look behind.

But you can reverse the string, and look for an even amount of trailing backslashes. After splitting, you need to do some reversing again:

reverse map {scalar reverse} split /:(?=(?:\\\\)*(?!\\))/ => reverse $ +string;

Abigail

Replies are listed 'Best First'.
Re: Re: split on unescaped delimiters
by bsb (Priest) on Jan 08, 2004 at 10:17 UTC
    Very, very nice.

    Even eh? Reminds my of your prime matching japh
    ...thinking music...

    No good. The split would still take the slashes and lookbehind is fixed length.