my $str = "a2b c34d"; $str =~ /(\D\d\D)/; print "$1\n"; # prints: 'a2b' $str =~ s/$1/NEW/; print "$str\n"; # prints: 'NEW c34d'