title: Python regex replace list of pattern
body: <p>I have a list of patterns:</p>
  <pre><code>patterns = [&quot;how&quot;, &quot;do you do&quot;, &quot;are you doing&quot;, &quot;goes it&quot;]
  </code></pre>
  <p>Any occurrences of list's items in string should be replaced to <strong>&quot;how are you&quot;</strong>.</p>
  <p><em>For example:</em></p>
  <p>String <strong>&quot;how do you do?&quot;</strong> should be replaced to <strong>&quot;how are you?&quot;</strong></p>
  <p><em>What I use:</em></p>
  <pre><code>s = input()  
  for pattern in patterns:
         s = re.sub(rf&quot;(\b{pattern}\b)&quot;, &quot;how are you&quot;, s)
  </code></pre>
  <p>The problem is that I receive <strong>&quot;how are you how are you&quot;</strong>.</p>
  <p>The easiest solution is to change list of patterns to:</p>
  <pre><code>patterns = [&quot;how do you do&quot;, &quot;how are you doing&quot;, &quot;how goes it&quot;]
  </code></pre>
  <p><em><strong><strong>But I need to keep &quot;how&quot; in list and keep it separately from other items.</strong></strong></em></p>