in reply to split unless escaped

if you use (?: ) (do not make backreference) you can go with out the second line.
@a = split /(?<!\\)(?:\\\\)*&/, "a=1&b=2\\&3&c=4"; print join("|",@a)."\n"; @b = split /(?<!\\)(\\\\)*&/, "a=1&b=2\\&3&c=4"; $b[$_] .= splice @b, $_ + 1, 1 for (0..($#b/2)); print join("|",@b)."\n";

Replies are listed 'Best First'.
RE: RE: split unless escaped
by ZZamboni (Curate) on Apr 25, 2000 at 21:15 UTC
    The problem is that then you lose any trailing double-backslashes, which are correctly kept in the OP method. For example, try it with the string 'a=1&b=2\&3\\&c=4'.