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

This is a bit weird, but it seems to work:

$text =~ s/\s+|(STARTPRESERVE(\d?).*?STOPPRESERVE$1)/${[$1,' ']}[!$1]/gs;

update: see merlin below. Now it works with nested PRESERVEs:

$text =~ s/\s+|(STARTPRESERVE(\d?).*?STOPPRESERVE\2)/${[$1,' ']}[!$1]/ +gs;

Replies are listed 'Best First'.
•Re: Re: RegEx filter \s ! between labels, part 2
by merlyn (Sage) on Oct 02, 2002 at 18:02 UTC