$string = 'isasdffdsakk'; if($string =~ /(.*?)(reverse\1)/s){ print $1,$2; }