StringKeyValParser.cs 738 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Azylee.Core.DataUtils.StringUtils
  6. {
  7. public static class StringKeyValParser
  8. {
  9. public static string GetValue(string s, string key, string split, string end, string defaultValue = "")
  10. {
  11. string head = key + split;
  12. int valBegIndex = s.IndexOf(head) + head.Length;
  13. if (valBegIndex >= 0)
  14. {
  15. int valEndIndex = s.IndexOf(end, valBegIndex);
  16. if (valEndIndex >= 0)
  17. {
  18. return s.Substring(valBegIndex, valEndIndex - valBegIndex);
  19. }
  20. }
  21. return defaultValue;
  22. }
  23. }
  24. }