fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string str = @"stackoverflow(stack:stackoverflow)overstackflow(over:stackoverflow)";
  9. IList<String> foundStrings = new List<String>();
  10. int currentIndex = 0;
  11. int index = str.IndexOf("(", currentIndex);
  12. while (index != -1)
  13. {
  14. int start = index + "(".Length;
  15. int colonIndex = str.IndexOf(":", start);
  16. if (colonIndex != -1)
  17. {
  18. string nextFound = str.Substring(start, colonIndex - start);
  19. foundStrings.Add(nextFound);
  20. }
  21. currentIndex = start;
  22. index = str.IndexOf("(", currentIndex);
  23. }
  24. foreach(string found in foundStrings)
  25. Console.WriteLine(found);
  26. }
  27. }
Success #stdin #stdout 0.05s 34848KB
stdin
Standard input is empty
stdout
stack
over