use strict; use warnings; my $str = "25364-564756ABCD"; $str =~ /-\d*?(\d{2}).*$/; print $1;