title: String replace digits 0123456789 with X in Swift iOS
body: <p>Need to replace phone number list with X and format should stay the same.</p>
  <p>For example:</p>
  <ol>
  <li>Input-&gt; <strong>201-555-0123</strong> -&gt; Expected Output: <strong>XXX-XXX-XXXX</strong></li>
  <li>Input-&gt; <strong>612 34 56 78</strong> -&gt; Expected Output: <strong>XXX XX XX XX</strong></li>
  <li>Input-&gt; <strong>9 11 2345-6789</strong> -&gt; Expected Output: <strong>X XX XXXX-XXXX</strong></li>
  <li>Input-&gt; <strong>622-1234</strong> -&gt; Expected Output: <strong>XXX-XXXX</strong></li>
  </ol>
  <p>Can anyone suggest proper way of finding digits 0 to 9 in the string and replace with X.</p>
  <p>Tried as below it doesn't finds number and returns same.</p>
  <pre><code>func getMaskedNumber(formattedPhoneNumber: String) -&gt; String {
          let maskedNumber = formattedPhoneNumber.replacingOccurrences(of: &quot;[0-9]&quot;, with: &quot;X&quot;)
          return maskedNumber
  }
  </code></pre>
  <pre><code> numberToDisplay = getMaskedNumber(formattedPhoneNumber: &quot;201-555-0123&quot;) // Expected O/P as XXX-XXX-XXXX
  </code></pre>