title: Replace all the occurrences of specific words
body: <p>Suppose that I have the following sentence:</p>
  
  <pre><code>bean likes to sell his beans
  </code></pre>
  
  <p>and I want to replace all occurrences of specific words with other words. For example, <code>bean</code> to <code>robert</code> and <code>beans</code> to <code>cars</code>. </p>
  
  <p>I can't just use <code>str.replace</code> because in this case it'll change the <code>beans</code> to <code>roberts</code>. </p>
  
  <pre><code>&gt;&gt;&gt; "bean likes to sell his beans".replace("bean","robert")
  'robert likes to sell his roberts'
  </code></pre>
  
  <p>I need to change the whole words only, not the occurrences of the word in the other word. I think that I can achieve this by using regular expressions but don't know how to do it right.</p>