标签:
/// <summary> /// 取中间文本 /// </summary> /// <param name="SumString">总文本</param> /// <param name="LeftString">左边文本</param> /// <param name="RightString">右边文本</param> /// <returns>找到返回取出的中间文本,没找到返回空</returns> public static string GetMiddleString(string SumString, string LeftString, string RightString) { if (string.IsNullOrEmpty(SumString)) return ""; if (string.IsNullOrEmpty(LeftString)) return ""; if (string.IsNullOrEmpty(RightString)) return ""; int LeftIndex = SumString.IndexOf(LeftString); if (LeftIndex == -1) return ""; LeftIndex = LeftIndex + LeftString.Length; int RightIndex = SumString.IndexOf(RightString, LeftIndex); if (RightIndex == -1) return ""; return SumString.Substring(LeftIndex, RightIndex - LeftIndex); }
标签:
原文地址:http://www.cnblogs.com/xiaomihu/p/5819767.html