fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test {
  5. public static void Main() {
  6.  
  7. string[] numbers = {"123_555-0190", "444-234-22450", "690-555-0178",
  8. "146-893-232", "146-555-0122", "4007-555,-0111",
  9. "407-55-0111", "a1b-Cd-EfgH", "a1b-Cd-Efgn",
  10. "UM2345678",
  11. "11/12/2013 4:10:06 PM UM2345678 UM2345678",
  12. "407-2-5555"};
  13.  
  14. foreach (string s in numbers) {
  15. string a = RemoveSpecialCharacters(s);
  16. Console.WriteLine(a);
  17. }
  18.  
  19. }
  20.  
  21. public static string RemoveSpecialCharacters(string str) {
  22. return Regex.Replace(str, "[^a-zA-Z0-9_.,\t-]+", "", RegexOptions.Compiled);
  23. }
  24. }
Success #stdin #stdout 0.06s 33912KB
stdin
Standard input is empty
stdout
123_555-0190
444-234-22450
690-555-0178
146-893-232
146-555-0122
4007-555,-0111
407-55-0111
a1b-Cd-EfgH
a1b-Cd-Efgn
UM2345678
1112201341006PM		UM2345678			UM2345678
407-2-5555