Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Replacing string with its length in Regex

by bikeNomad (Priest)
on Jul 27, 2001 at 20:34 UTC ( #100359=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://100359]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2021-05-11 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (109 votes). Check out past polls.

    Notices?