I want to use a string phoneNumber, which is a phone number, to call this number on mobile devices.
How can I shorten the phoneNumber string to just digits and plus signs?
e.g.
phoneNumber = "+49 / 123 – 456.89"
I like to get: "+4912345678"
>Solution :
You can use:
var cleanNumber = phoneNumber.Where(c => c == '+' || Char.IsDigit(c));
string result = String.Concat(cleanNumber);
https://dotnetfiddle.net/dybS5e