fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Example
  5. {
  6. public static void Main()
  7. {
  8. string pattern = @"(?<!\S)(?:x+(?:-x+)*|\d+(?:-\d+)*)$";
  9. string input = @"Isaiah Kinney 06/2021 111111
  10. Darius Knox 10/2020 111-334-555
  11. Leo Wiley 07/2020 122-333
  12. Stone Walls 11/2020 2112333
  13. John Stone 12/2021 xxx-xx-xxx";
  14. RegexOptions options = RegexOptions.Multiline;
  15.  
  16. foreach (Match m in Regex.Matches(input, pattern, options))
  17. {
  18. Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
  19. }
  20. }
  21. }
Success #stdin #stdout 0.06s 21188KB
stdin
Standard input is empty
stdout
'111111' found at index 22.
'111-334-555' found at index 49.
'122-333' found at index 79.
'2112333' found at index 107.
'xxx-xx-xxx' found at index 134.