C# GetValue 正则获取开始结束代码

        /// <summary>
        /// 获得字符串中开始和结束字符串中间得值
        /// </summary>
        /// <param name="str">字符串</param>
        /// <param name="s">开始</param>
        /// <param name="e">结束</param>
        /// <returns></returns> 
        public string GetValue(string str, string s, string e)
        {
            Regex rg = new Regex("(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))", RegexOptions.Singleline);
            return rg.Match(str).Value;
        }

  

posted @ 2017-05-27 16:15  懒人境界  阅读(334)  评论(0编辑  收藏  举报