0

I need to remove parentheses from a phone number as below. But with following code I can only remove spaces. How can I improve this method to clean the phone string from all other possible chars?

Cheers

 string phone = "(123)234 5566"; //(+954)123 3456
 string phone = prep_numbers(@"/[^0-9]/", "", phone);

 public static string prep_numbers(string pattern, string replacement, string subject)
    {
        string str = Regex.Replace(subject, pattern, replacement);
        str = str.Replace(" ", String.Empty);
        return str;
    }
Roshan Ruzaik
  • 121
  • 1
  • 6

0 Answers0