$str = 'green beans are great?';
preg_match('#[\w.?!]+$#', $str, $match);
echo $match[0];
ouputs:
great?
I added the .?! in case you need the punctuation as well.. if not, then simply use this instead:
$str = 'green beans are great?';
preg_match('#(\w+)[.!?]?$#', $str, $match);
echo $match[1];
ouputs:
great
This second example checks for any of the listed punctuation marks in the character class as optional (but is not included in the capture).