正则获取字符串中两个字符串间的内容

/// <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);
Match matchs = rg.Match(str);

return matchs.Groups[0].Value + matchs.Groups[2].Value;
}

posted on 2016-04-13 08:51  wolf12  阅读(1753)  评论(0编辑  收藏  举报