$text = "the dog and the bear are quick, but the quick fox is quicker"; $re = "the\\b.*?quick\\b.*?fox"; print "it matches \n" if ($text =~ /($re)/sg); print $1 . "\n";