fork(1) 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 xmlLine = "[<colors numResults=\"100\" totalResults=\"6806926\">]";
  13. string pattern = "totalResults=\"";
  14. int startIndex = xmlLine.IndexOf(pattern);
  15. if(startIndex >= 0)
  16. {
  17. startIndex += pattern.Length;
  18. int endIndex = xmlLine.IndexOf("\"", startIndex);
  19. if(endIndex >= 0)
  20. {
  21. string totalResultPart = xmlLine.Substring(startIndex,endIndex - startIndex);
  22. // if you want to calculate with it
  23. int totalResults = int.Parse(totalResultPart);
  24. Console.WriteLine("Total-result is: " + totalResults);
  25. }
  26. }
  27. }
  28. }
Success #stdin #stdout 0.05s 34016KB
stdin
Standard input is empty
stdout
Total-result is: 6806926