Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047399]
help
Chatterbox?
[Corion]: The upside to this is that I've reduced my $work (well, $paid) time to 80%, so I'll be at $work only four days/week, which will hopefully make the crunch less crunchy on me ;)
[marto]: yeah, so that stays as before. But before the boys were born I'd be on quite often at night (GMT) also
[marto]: I had the option during our TUPE transfer to buy 5 more days holiday. They were shocked when I did :P

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-06-29 08:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (655 votes). Check out past polls.