Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Replacing string with its length in Regex

by bikeNomad (Priest)
on Jul 27, 2001 at 20:34 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://100359]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-20 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found