use strict; use warnings; my $string="welcomezxyaaaaa"; $string=~s/([b-w]+)[^a]+([a]+)/uc($1)/ge; print $string;