if ($text =~ /\bstart\b(.*?)\bend\b/) { $result = $1; # do something with results }