But finally I got it. I really hope that it will save someone just a small part of the time it took me to figure.
If anyone can do it one line I would like to know, this is a kind of hack, though a good one.
The regexp says: split on & preceded by any even number of backslashes, which is not preceded by a síngle backslash. The idea is to find a uneven number or backlashes. Unfortunately the implementation of split is less than perfect which is why the second line is needed. It cleans up the extra fields that get produced.
think perl for perl is the most elevated
/dh
@a = split /(?<!\\)(\\\\)*&/, "a=1&b=2\\&3&c=4"; $a[$_] .= splice @a, $_ + 1, 1 for (0..($#a/2));
In reply to split unless escaped by da'ud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |