in reply to Re^3: doubt in matching
in thread doubt in matching

"thhheeee good boyy" should be "t(hhh)(eeee) g(oo)d bo(yy)"
In that case, maybe you want something like this:
#!/usr/bin/perl -w use strict; while (<DATA>) { chomp; $_ =~ s/(\w)(\1+)/\($1$2\)/g; print "$_\n"; } __DATA__ thhheeee good boyy the qqquick brrrowwwn fooox
Output:
t(hhh)(eeee) g(oo)d bo(yy) the (qqq)uick b(rrr)o(www)n f(ooo)x
Cheers,
Darren :)