in reply to Replacing string with its length in Regex
my $s = s/_*(X+)_*/length($1) . ','/ge; $s =~ s/,$//; [download]
$r =~ s/(^_+|_+$)//g; $r =~ s/_+/,/g; $r =~ s/(X+)/length$1/ge; [download]