fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. string pattern = @"^(?!0+$)(\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4}))$";
  10.  
  11. var strings = new List<string>() {
  12. "4561237890",
  13. "1234",
  14. "0000000000"
  15. };
  16. foreach (var input in strings)
  17. {
  18. foreach (Match m in Regex.Matches(input, pattern))
  19. {
  20. Console.WriteLine(m.Value);
  21. }
  22. }
  23. }
  24. }
Success #stdin #stdout 0.1s 29824KB
stdin
Standard input is empty
stdout
4561237890