$re = '/(?<!\\\\senator{})Bernie Sanders(?!\s*})/m';
$str = 'Bernie Sanders
\\senator{Bernie Sanders}
The senator of Vermont is \\senator{Bernie Sanders}.
A \\texttt{senator of Vermont} is Bernie Sanders.
A senator of Vermont is \\textit{Bernie Sanders}.
\\textit{Bernie Sanders} is a senator of Vermont.
Is this the same Bernie Sanders?
Is Bernie Sanders a good senator?
Will we ever see a \\textbf{President Bernie Sanders}?';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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