随手记一次用C#正则表达式获取下拉菜单html标签<select>以及相关属性值

随手记一次用C#正则表达式获取下拉菜单html标签<select>以及相关属性值


1:有如下html:

..................

<select id="aaa" style="width: 152px;" name="aaa">
<option selected="selected" value="1"></option>
<option selected="selected" value="1">今天</option>
<option value="2">明天</option>
<option value="3">后天</option>
</select>

...................

2:C# 正则表达式:

string option = Regex.Match(html, "<select.*(?=dropServer)(.|\n)*?</select>").Value;

即可匹配以上html

 

3:json字符串中Unicode字符转码问题:

直接调用C#中  

Regex.Unescape(str)方法

即可。

资料参考:https://msdn.microsoft.com/zh-cn/library/system.text.regularexpressions.regex.unescape.aspx

posted @ 2015-11-18 19:03  大白的记事本  阅读(750)  评论(0编辑  收藏  举报