title: How to replace multiple words with space in a string using Java
body: <p>I tried to replace a list of words from a give string with the following code. </p>
  
  <pre><code>String Sample = " he saw a cat  running of that pat's mat ";
  String regex = "'s | he | of | to | a | and | in | that";
  Sample = Sample.replaceAll(regex, " ");
  </code></pre>
  
  <p>The output is </p>
  
  <pre><code>[ saw cat  running that pat mat ] 
  // minus the []
  </code></pre>
  
  <p>It still has the last word "that". Is there anyway to modify the regex to consider the last word also.</p>