using System.Text.RegularExpressions; //正则
string strHtml = "
Belgium Belgien Urlaub Holidays Vakanties CenterParcs 10 000 000
TextBox1.Text = "" + strHtml + ""; Regex re = new Regex("(?<=
结果:
Belgium Belgien Urlaub Holidays Vakanties CenterParcs 10 000 000
/// <summary> /// 从文章内容中获取第一张图片,用作文章缩略图 /// </summary> /// <param name="articleContent"></param> /// <returns></returns> public static string GetImageUrlFromArticle( string articleContent) { Regex r = new Regex( @" <IMG[^>]+src=\s*(?:'(?<src>[^']+)'|""(?<src>[^""]+)""|(?<src>[^>\s]+))\s*[^>]*> " , RegexOptions.IgnoreCase); MatchCollection mc = r.Matches(articleContent); if (mc.Count != 0 ) { return mc[ 0 ].Groups[ " src " ].Value.ToLower(); } else { return "" ; } }
本文转自曾祥展博客园博客,原文链接:http://www.cnblogs.com/zengxiangzhan/archive/2009/12/21/1629364.html,如需转载请自行联系原作者