fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var lst = new List<string> {"70707_70708_70709_display1.jpg",
  12. "70707_Front010.jpg",
  13. "626-this files is tagged.jpg",
  14. "1000x1000_webbanner2.jpg",
  15. "2000 years ago_files.jpg",
  16. "626gamingassets_styleguide.jpg" };
  17. foreach (var s in lst)
  18. {
  19. var mcoll = Regex.Matches(s, @"^(?<v>\d{3,})(?:_(?<v>\d{3,}))*_")
  20. .Cast<Match>()
  21. .SelectMany(m => m.Groups["v"].Captures.Cast<Capture>().Select(c => c.Value))
  22. .ToList();
  23. if (mcoll.Count > 0)
  24. Console.WriteLine("Results: {0}", string.Join(", ", mcoll));
  25. else
  26. Console.WriteLine("No match: '{0}'", s);
  27. }
  28. }
  29. }
Success #stdin #stdout 0.06s 133824KB
stdin
Standard input is empty
stdout
Results: 70707, 70708, 70709
Results: 70707
No match: '626-this files is tagged.jpg'
No match: '1000x1000_webbanner2.jpg'
No match: '2000 years ago_files.jpg'
No match: '626gamingassets_styleguide.jpg'