日期:2014-05-18 浏览次数:20826 次
#region 取中间内容 /// <summary> /// 取中间内容 /// </summary> /// <param name="text">要输入的文本</param> /// <param name="start">取内容的前面</param> /// <param name="end">取内容的后面</param> /// <returns></returns> public string Middle(string text, string start, string end) { Regex regex = new Regex(string.Format("(?<={0}).*(?={1})", start, end)); Match flag = regex.Match(text); return flag.Value; } #endregion
#region 取中间内容 /// <summary> /// 取中间内容 /// </summary> /// <param name="text">要输入的文本</param> /// <param name="start">取内容的前面</param> /// <param name="end">取内容的后面</param> /// <returns></returns> public string Middle(string text, string start, string end) { Regex regex = new Regex(string.Format("(?<={0}).*(?={1})", Regex.Escape(start), Regex.Escape(end))); Match flag = regex.Match(text); return flag.Value; } #endregion