Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: repeated characters in regular expressions

by jwkrahn (Monsignor)
on Aug 01, 2013 at 09:07 UTC ( #1047399=note: print w/ replies, xml ) Need Help??


in reply to repeated characters in regular expressions

$ perl -le' my $n = 4; my $m = 1; $_ = "p8888er9999l"; print; s/((.)\2*)/ $n == length $1 ? $2 x $m : $1 /eg; print; ' p8888er9999l p8er9l $ perl -le' my $n = 1; my $m = 3; $_ = "monks"; print; s/((.)\2*)/ $n == length $1 ? $2 x $m : $1 /eg; print; ' monks mmmooonnnkkksss


Comment on Re: repeated characters in regular expressions
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-11-27 22:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (188 votes), past polls