title: Replace all occurrences that match regular expression
body: <p>I have a regular expression that searches for a string that contains <code>'.00.'</code> or <code>'.11.'</code> as follows:</p>
  
  <pre><code>.*\.(00|11)\..*
  </code></pre>
  
  <p>What I would like to do is replace all occurrences that match the pattern with <code>'X00X'</code> or <code>'X11X'</code>. For example, the string <code>'.00..0..11.'</code> would result in <code>'X00X.0.X11X'</code>. </p>
  
  <p>I was looking into the Python re.sub method and am unsure of how to do this effectively. The returned match object only matches on the first occurrence and therefore doesn't work well. Any advice? Should I just be using a string replace for this task? Thanks.</p>