zoukankan      html  css  js  c++  java
  • C#中用正则表达示过滤出HTML代码中的所有图片

      string str = "sdfdfd<img name=''src='http://cp.a8.com/image/128X128GIF/50686.gif' width='32' height='32' alt='' />dsfsdfsdf<img name=''src='http://cp.a8.com/image/128X128GIF/53075.gif' width='32' height='32' alt='' />dsfffffffff<img name=''src='http://cp.a8.com/image/128X128GIF/53099.gif' width='32' height='32' alt='' />";
            str += "sdfdfd<img name=''src='http://cp.a8.com/image/128X128GIF/50686.gif' width='32' height='32' alt='' />dsfsdfsdf<img name=''src='http://cp.a8.com/image/128X128GIF/53075.gif' width='32' height='32' alt='' />dsfffffffff<img name=''src='http://cp.a8.com/image/128X128GIF/53099.gif' width='32' height='32' alt='' />";
            Regex r = new Regex("<img.{25,100}/>");
            MatchCollection mc = r.Matches(str);
       
            string[] results = new string[mc.Count];
            for (int i = 0; i < mc.Count; i++)
            {
                results[i]=(mc[i].Value);
         

            }
            // List the results.
            for (int ctr = 0; ctr <= results.Length - 1; ctr++)
            {
                Response.Write( results[ctr]);
                Response.Write("<br>");

            }
            Response.Write(results.Length);

  • 相关阅读:
    南阳理工ACM1076--方案数量
    南阳理工oj88--汉诺塔(一)
    杭电ACM1170--Balloon Comes!
    杭电ACM2011-- 多项式求和
    杭电ACM2080--夹角有多大II
    杭电ACM2076--夹角有多大(题目已修改,注意读题)
    请!继续!
    南阳理工ACM954--N!
    南阳理工ACM975--关于521
    致自己即将到来的人生
  • 原文地址:https://www.cnblogs.com/yeye518/p/2231712.html
Copyright © 2011-2022 走看看