in reply to Replacing string with its length in Regex

Why not just:

my $s = s/_*(X+)_*/length($1) . ','/ge; $s =~ s/,$//;

Replies are listed 'Best First'.
Re: Re: Replacing string with its length in Regex
by petral (Curate) on Jul 29, 2001 at 12:28 UTC
    even simpler:
    $r =~ s/(^_+|_+$)//g; $r =~ s/_+/,/g; $r =~ s/(X+)/length$1/ge;
      p