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. public static void Main()
  9. {
  10. string text = "abc xyz: ID# 1000123, this is test, test 1, test 1234, ";
  11. string id = null;
  12. int idIndex = text.IndexOf("ID# ");
  13. if(idIndex != -1)
  14. {
  15. idIndex += "ID# ".Length;
  16. int commaIndex = text.IndexOf(',', idIndex);
  17. if(commaIndex != -1)
  18. id = text.Substring(idIndex, commaIndex - idIndex);
  19. else
  20. id = text.Substring(idIndex);
  21. }
  22. Console.WriteLine(id);
  23. }
  24. }
Success #stdin #stdout 0.05s 33872KB
stdin
Standard input is empty
stdout
1000123