title: Regex match entire words only
body: <p>I have a regex expression that I'm using to find all the words in a given block of content, case insensitive, that are contained in a glossary stored in a database. Here's my pattern:</p>
  
  <pre><code>/($word)/i
  </code></pre>
  
  <p>The problem is, if I use <code>/(Foo)/i</code> then words like <code>Food</code> get matched.  There needs to be whitespace or a word boundary on both sides of the word.</p>
  
  <p>How can I modify my expression to match only the word <code>Foo</code> when it is a word at the beginning, middle, or end of a sentence?</p>