in reply to Replace repeated characters with *
A simple regular expression makes it easy:
use strict; use warnings; my $str = "Foooboooobaaar"; $str =~ s/(.)\1+/$1*/g; print "\n$str";
Prints:
Fo*bo*ba*r
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replace repeated characters with *
by Anonymous Monk on Jul 03, 2009 at 11:50 UTC |