title: How to replace phone number with Xs?
body: <p>I use the following regex to find phone number in the text (number could be with or without country code, with different separators etc.):</p>
  
  <pre><code>phonePattern = re.compile(".*?\d?(\(?\d{3}\D{0,3}\d{3}\D{0,3}\d{4}).*?", re.S)
  result = phonePattern.search(text)
  </code></pre>
  
  <p>Now I would like to replace digits with Xs. For ex., if I found phone like <code>1 (123) 123-4567</code>, then it should be replaced with <code>1 (XXX) XXX-XXXX</code> in the text. How can I do it?</p>