• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: String replace digits 0123456789 with X in Swift iOS

Resolved: String replace digits 0123456789 with X in Swift iOS

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Need to replace phone number list with X and format should stay the same.
For example:
  1. Input-> 201-555-0123 -> Expected Output: XXX-XXX-XXXX
  2. Input-> 612 34 56 78 -> Expected Output: XXX XX XX XX
  3. Input-> 9 11 2345-6789 -> Expected Output: X XX XXXX-XXXX
  4. Input-> 622-1234 -> Expected Output: XXX-XXXX

Can anyone suggest proper way of finding digits 0 to 9 in the string and replace with X.
Tried as below it doesn’t finds number and returns same.

Answer:

You can use regex. Try this:

If you have better answer, please add a comment about this, thank you!

ios regex swift
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to set consistent decimal separators in R data frame?

26/03/2023

Resolved: How to resolve LNK2001 in c++ projects

26/03/2023

Resolved: How to correctly initialize vector of number in Typescript

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.