Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在.net中从类文件读取内联样式_Html_.net_Regex - Fatal编程技术网

Html 在.net中从类文件读取内联样式

Html 在.net中从类文件读取内联样式,html,.net,regex,Html,.net,Regex,我需要从.net类文件的html元素中获取样式 尝试使用此正则表达式:style=“[^”]+” 您可以使用style=“.*”regex *?将不精确地匹配任何字符(因此,不会占用'src'属性) C#代码: var输入=”; var MyRegex=new Regex(@“style=”“.*”); var result=MyRegex.Match(输入).Value; var input = "<img alt=\"\" style=\"width: 81px; height:

我需要从.net类文件的html元素中获取样式


尝试使用此正则表达式:
style=“[^”]+”

您可以使用
style=“.*”
regex

*?
将不精确地匹配任何字符(因此,不会占用'src'属性)

C#代码:

var输入=”;
var MyRegex=new Regex(@“style=”“.*”);
var result=MyRegex.Match(输入).Value;
 var input = "<img alt=\"\" style=\"width: 81px; height: 61px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: inherit; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px;\" src=\"\"https://www.google.co.in/images/srpr/logo11w.png\"\" />";
 var MyRegex = new Regex(@"style="".*?""");
 var result = MyRegex.Match(input).Value;