Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Regexp: can I do it in one go?

by jmcnamara (Monsignor)
on Aug 22, 2002 at 11:34 UTC ( #191988=note: print w/replies, xml ) Need Help??


in reply to Regexp: can I do it in one go?


You can use a backreference to obtain a single regex:
#!/usr/bin/perl -wl use strict; my $s = 'aaaabababbbbaaaccccbbbbbbaadddd'; print $s; $s =~ s/((.)\2+)/length($1) . $2/eg; print $s; __END__ Prints: aaaabababbbbaaaccccbbbbbbaadddd 4ababa4b3a4c6b2a4d

--
John.

Replies are listed 'Best First'.
Re: Re: Regexp: can I do it in one go?
by moxliukas (Curate) on Aug 22, 2002 at 11:40 UTC

    Thanks a lot. I can't believe that I didn't think about it this way ;)

    Thank you again

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2022-06-27 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (88 votes). Check out past polls.

    Notices?