我正在尝试匹配任何代词的组合以及最接近字符串末尾的任何副词。所以在下面的例子中,我试图让它匹配“她是”这个词,因为它最接近字符串的结尾。我该怎么办?
$pronounsMatch = "i|me|my|you|your|it|he|she|her|his|us|our|they|their|them|this|these|that|those|the|yourself|myself";
$adverbsMatch = "may|do|dont|does|doesnt|did|didnt|am|is|isnt|was|wasnt|were|werent|are|arent|can|cant|could|couldnt|will|wont|would|wouldnt|should|shouldnt|have|havent|has|hasnt|had|hadnt";
$temp = "i am so into food and he is here but she is not";
preg_match("~\b($pronounsMatch) ($adverbsMatch)\b(.+)? ([a-z]+)$~", $temp, $match);
print_r($match);
Array ( [0] => i am so into food and he is here but she is not [1] => i [2] => am [3] => so into food and he is here but she is [4] => not )
现在它匹配最接近字符串开头的组合,即“我是”。我该如何解决这个问题?