fork download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. public class Test
  7. {
  8.  
  9.  
  10. public static void Main()
  11. {
  12. string text = "blub ASP.filename_aspx foo ASP.filename2_aspx bah ...";
  13. var matches = new List<string>();
  14. int index = text.IndexOf("ASP", StringComparison.OrdinalIgnoreCase);
  15. int endIndex = index >= 0 ? text.IndexOf("_aspx", index + 1, StringComparison.OrdinalIgnoreCase) : -1;
  16. while (index >= 0 && endIndex >= 0)
  17. {
  18. index += "ASP.".Length;
  19. endIndex += "_aspx".Length;
  20. matches.Add(text.Substring(index, endIndex - index));
  21. index = text.IndexOf("ASP", endIndex + 1, StringComparison.OrdinalIgnoreCase);
  22. endIndex = index >= 0 ? text.IndexOf("_aspx", index + 1, StringComparison.OrdinalIgnoreCase) : -1;
  23. }
  24. foreach(var str in matches)
  25. Console.WriteLine(str);
  26. }
  27. }
Success #stdin #stdout 0.03s 33832KB
stdin
Standard input is empty
stdout
filename_aspx
filename2_aspx