获取两个字符串中间部分的值

获取两个字符串中间部分的值

 #region 取得两个符串中间的部分
        public static string GetStrFG(string str1, string headstr, string endstr)
        {
            MatchCollection mc;
            Regex r = new Regex(@"(?<=" + headstr + ").*?(?=" + endstr + ")", RegexOptions.Singleline | RegexOptions.IgnoreCase); //定义一个Regex对象实例
            mc = r.Matches(str1);
            if (mc.Count > 0) return (mc[0].Value); else { return (""); }
        }
        #endregion