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