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 line = "Duration: 00:00:02.60, start: 0.000000, bitrate: 517 kb/s";
  13. string pattern = "bitrate: ";
  14. int bitrate = -1;
  15. int index = line.IndexOf(pattern, StringComparison.OrdinalIgnoreCase);
  16. if(index >= 0)
  17. {
  18. index += pattern.Length;
  19. int endIndex = line.IndexOf(" kb/s", index + 1, StringComparison.OrdinalIgnoreCase);
  20. if(endIndex >= 0)
  21. {
  22. int.TryParse(line.Substring(index, endIndex - index), out bitrate);
  23. }
  24. }
  25. Console.Write("Bitrate: " + bitrate);
  26. }
  27. }
Success #stdin #stdout 0.03s 34800KB
stdin
Standard input is empty
stdout
Bitrate: 517