my $str='-plastic-Protector/dp/B00074658'; if($str =~m/dp\/(.+?)$/){ print $1,$/; # print B00074658 }