Question:
Need to replace phone number list with X and format should stay the same.For example:
- Input-> 201-555-0123 -> Expected Output: XXX-XXX-XXXX
- Input-> 612 34 56 78 -> Expected Output: XXX XX XX XX
- Input-> 9 11 2345-6789 -> Expected Output: X XX XXXX-XXXX
- 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!