AmnonM has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I want to look through a string, and if I find n repeated characters, I want to replace them with m of the same character. Probably a simple regexp for a monk?
e.g., if n=4 and m=1 then... p8888er9999l --> p8er9l
if n=1 and m=3 monks --> mmmooonnnkkksss
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: repeated characters in regular expressions
by kcott (Archbishop) on Aug 01, 2013 at 08:03 UTC | |
by AmnonM (Initiate) on Aug 01, 2013 at 08:10 UTC | |
|
Re: repeated characters in regular expressions
by Loops (Curate) on Aug 01, 2013 at 07:57 UTC | |
|
Re: repeated characters in regular expressions
by jwkrahn (Abbot) on Aug 01, 2013 at 09:07 UTC | |
|
Re: repeated characters in regular expressions
by Utilitarian (Vicar) on Aug 01, 2013 at 07:54 UTC | |
by Loops (Curate) on Aug 01, 2013 at 08:03 UTC |