title: regex to replace a whole word, not characters
body: <p>i have the following snippet:</p>
  <pre><code>String[] alsoReplace = {&quot;and&quot;, &quot;the&quot;, &quot;&amp;&quot;};
      for (String str : alsoReplace) {
          s = s.replaceAll(&quot;(?i)&quot; + str + &quot;(\\s+)?&quot; , &quot;&quot;);
      }
  </code></pre>
  <p>I need to alter the regex in it, so as to replace the &quot;and&quot; or &quot;the&quot; found in a string as a word, not as just part of a word.</p>
  <p>example:</p>
  <p>Dean and James -&gt; Dean James</p>
  <p>Deand James -&gt; Deand James</p>
  <p>I also need to keep the case insensitive replacement,</p>
  <p>how this line should become?</p>
  <pre><code>        s = s.replaceAll(&quot;(?i)&quot; + str + &quot;(\\s+)?&quot; , &quot;&quot;);
  </code></pre>