$re = '/\.\K\h*[Jj]ack,? is[^.\n]*\.$/m';
$str = 'Jack is the tallest person.
and Jack is the one who said, let there be fries.
There are mirrors. And Jack is there to be suave.
There are dogs. And jack is there to pat them. Very cool.
Jack is your lumberjack. Jack, is super awesome.
Whereas Jack is, for the whole summer, sound asleep. Zzzz
\'Jack is so cool!\' Jack is cool. Jack is also cold.';
$subst = " [TRIM]";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php