1

我在文本中遇到了“匹配器”css 样式的问题。我想获得以下风格:

风格搜索

<a id="d325" style="color: #ffffff;"> Visio Infrastructure and Applications </ a>

使用的正则表达式:

Regex myRegex = new Regex(@"<a id=""d(.+?)"" style=""(.+)"" ><\/a>");

我认为问题是style = "color: # fffff",但我就是无法理解。

非常感谢

4

2 回答 2

3

您的正则表达式的问题是

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   

另一个问题是,正则表达式是否适合这项工作?

于 2013-01-18T09:20:37.983 回答
0

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

<a\sid="d(.+?)"\sstyle="(.+)">.*?</a>

你得到了结果:325颜色:#ffffff

是你想要的结果吗?

于 2013-01-18T09:25:33.160 回答