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