Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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
C# 如何在C中匹配css样式的文本#_C#_Css_Regex_Match - Fatal编程技术网

C# 如何在C中匹配css样式的文本#

C# 如何在C中匹配css样式的文本#,c#,css,regex,match,C#,Css,Regex,Match,我遇到了文本中“matcher”css样式的问题。 我想得到以下样式: 样式搜索 <a id="d325" style="color: #ffffff;"> Visio Infrastructure and Applications </ a> Visio基础架构和应用程序 使用的正则表达式: Regex myRegex = new Regex(@"<a id=""d(.+?)"" style=""(.+)"" ><\/a>"); Regex

我遇到了文本中“matcher”css样式的问题。 我想得到以下样式:

样式搜索

<a id="d325" style="color: #ffffff;"> Visio Infrastructure and Applications </ a>
Visio基础架构和应用程序
使用的正则表达式:

Regex myRegex = new Regex(@"<a id=""d(.+?)"" style=""(.+)"" ><\/a>");
Regex-myRegex=newregex(@“);
我想问题是
style=“color:#fffff”
但我就是不明白


非常感谢

正则表达式的问题如下

Regex myRegex = new Regex(@"<a id=""d(.+?)"" style=""(.+)"" ><\/a>");
                                                           ^         no space in the string
                                                             ^       the text between the tags is not matched
                                                                ^    there is a space in the string   
Regex-myRegex=newregex(@“);
^字符串中没有空格
^标记之间的文本不匹配
^字符串中有一个空格

另一个问题是,正则表达式是这个工作的正确工具吗?

从我的角度来看,你只是忘记了正则表达式中的空白

<a\sid="d(.+?)"\sstyle="(.+)">.*?</a>
*?
您得到的结果是:325颜色:#ffffff


结果是你想要的吗?

对最后一部分的意见非常一致。使用HTML解析库解析HTML。那里有足够的空间1:绳子上没有空间?你这是什么意思?@MehdiBugnard,你的正则表达式在这一点上需要一个空格,但是在你想要匹配的字符串中,这一点上没有空格,所以正则表达式不能匹配Yes,因为你是对的!!这个正则表达式更好->正则表达式myRegex=newregex(@“.+?”)?看看这个,从html中获取信息。