title: A regex for the last use of a word in a string
body: <p>I'm trying to figure out how to grab the tail end of a string using a word as a delimiter, but that word can be used anywhere in the string. So only the last use would start the grab.</p>
  
  <p>example: <code>Go by the office and pickup milk by the safeway BY tomorrow</code></p>
  
  <p>I want to grab the <code>by tomorrow</code> and not the other <code>by</code>s</p>
  
  <p>This is the regex I'm trying to make robust:</p>
  
  <pre><code>$pattern = '/^(.*?)(@.*?)?(\sBY\s.*?)?(@.*)?$/i';
  </code></pre>
  
  <p>I think a negative lookahead would do it, but I've never used one before</p>
  
  <p>Thanks!</p>