c# 用正則表達式獲取開始和結束字符串中間的值
/// <summary> /// 獲得字符串中開始和結束字符串中間得值 /// </summary> /// <param name="str">字符串</param> /// <param name="s">開始</param> /// <param name="e">結束</param> /// <returns></returns> public static string GetValue(string str, string s, string e) { Regex rg = new Regex("(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))", RegexOptions.Multiline | RegexOptions.Singleline); return rg.Match(str).Value; }
