我有这个字符串文本:
<meta http-equiv="Content-Type" content="text/html;" charset="utf-8">
<style type="text/css">
body {
font-family: Helvetica, arial, sans-serif;
font-size: 16px;
}
h2 {
color: #e2703b;
}.newsimage{
margin-bottom:10px;
}.date{
text-align:right;font-size:35px;
}
</style>
为了清楚起见,添加了换行符和标识,真正的字符串没有它
如何获得h2
颜色的价值?在这种情况下应该是 -#e2703b;
我不知道在这种情况下如何使用正则表达式。
更新 如果我尝试这种方式:
Match match = Regex.Match(cssSettings, @"h2 {color: (#[\d|[a-f]]{6};)");
if (match.Success)
{
string key = match.Groups[1].Value;
}
它根本不起作用