in reply to Re: RegEx filter \s ! between labels, part 2
in thread RegEx filter \s ! between labels, part 2

$text =~ s/\s+|(STARTPRESERVE(\d?).*?STOPPRESERVE$1)/${[$1,' ']}[!$1]/ +gs;
No... that first $1 is freezing at the wrong time. Perhaps you mean \2, not $1.

-- Randal L. Schwartz, Perl hacker