Monday, 22 August 2022

Formatting phonenumber by removing all alphabets and characters except "+" and numbers in c#.

        public static string FormatPhoneNumber(string phoneNumber)
        {
            phoneNumber = Regex.Replace(phoneNumber, "[^0-9+]", "");
            if (phoneNumber == "+")
            {
                phoneNumber = string.Empty;
            }
            return phoneNumber;
        } 

No comments:

Post a Comment