in reply to edge case in substitution?
where (?<=&) and (?=&) are zero-width positive look-ahead and look-behind assertions. It can be simplified using negative assertions, at the cost of making it a little hard to wrap your head around initially, to:s{(?:(?<=&)|^) $tag=(.*?) (?:(?=&)|\z) ...
(Literally, match $tag=(.*?) only when not preceded or followed by a non-& character.)s{(?<![^&]) $tag=(.*?) (?![^&]) ...
|
|---|