my $text = "my dog is green"; my $count = $text =~ s/(g)(.)/$1$2/g; print $count;