首页 > 编程知识 正文

html如何加载本地图片,html中img标签的作用

时间:2023-05-04 14:53:59 阅读:116406 作者:1768

基本规格:

publicliststringmatchhtmlimgsrc (string html ) ) regeximgreg=newregex )、RegexOptions.IgnoreCase ); varimgs=imgreg.Matches(html ); regexsrcreg=new regex (src=['| " ]s ['" ],RegexOptions.IgnoreCase ); Liststring links=new Liststring (; Foreach(varimginimgs ) links.add ) srcreg.match ) img.ToString ) ).tostring ).replace ) ' src=',''').} )使用方法:

liststringimglinks=matchhtmlimgsrc (' img src='图像链接1'/img src='图像链接2'/' );

一个真实razor实例:

@ using system.text.regular expressions @ { layout='~~/views/shared/_ ask.cs html '; datatabletypedt=newb _ grade option (.getgradelist ) ) 2,0 ); 数据解决方案=(数据解决方案) ViewBag.solveDt; DataTable hotDt=(DataTable ) ViewBag.hotDt; //最近20起案件为fqdxmylastaskdt=ask bll.selpage (1,20,new Com_Filter ) }.dt; } @ functions { publicliststringmatchtmlimgsrc (string html ) regeximgreg=newregex('img[^]* ',regex options.ign nonon regexsrcreg=new regex (src=['| " ]s ['" ],RegexOptions.IgnoreCase ); Liststring links=new Liststring (; Foreach(varimginimgs ) links.add ) srcreg.match ) img.ToString ) ).tostring ).replace ) ' src=',''').} }……} div class=' qitem _ pic ' @ foreach (variteminmatchtmlimgsrc (dr (' q content ' ).tostring ) ) /这是引用的行id=@

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。