普通防爆pression让图像在C#中的SRC [英] Regular Expression to get the SRC of images in C#

查看:131
本文介绍了普通防爆pression让图像在C#中的SRC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一个正规的前pression隔离一个img的src值。
(我知道这是不是做到这一点的最好办法,但是这是我在这种情况下做的)

我有一个包含简单的HTML code,一些文本和图像的字符串。我需要从字符串src属性的值。我只有尽力把整个标签隔离到现在。

 字符串matchString = Regex.Match(original_t​​ext,@(小于IMG([^>] +)>))。值;


解决方案

 字符串matchString = Regex.Match(original_t​​ext,<?IMG + SRC = [\\']( ?+)[\\'​​] *方式>?,RegexOptions.IgnoreCase).Groups [1]。价值;

I'm looking for a regular expression to isolate the src value of an img. (I know that this is not the best way to do this but this is what I have to do in this case)

I have a string which contains simple html code, some text and an image. I need to get the value of the src attribute from that string. I have managed only to isolate the whole tag till now.

string matchString = Regex.Match(original_text, @"(<img([^>]+)>)").Value;

解决方案

string matchString = Regex.Match(original_text, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;

这篇关于普通防爆pression让图像在C#中的SRC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆