in reply to Re: Re: Re: highlight and line breaks
in thread highlight and line breaks

Not bad, but why try to match the tag again when you already let the engine match it before?
$_ = "foo<span>bar</span>bazqux<span>quux</span>"; my $c=0; s( (<span>|</span>|(.)) ) { defined $2 ? $1 . (++$c % 4 ? '' : "\n") : $1; }sxge; print; print "\n";

Makeshifts last the longest.