首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

求正则表达式(huangwenquan123),该如何解决

2012-04-18 
求正则表达式(huangwenquan123)获取到的html代码有多个select标签 我想获取C# codeselect nameProducts

求正则表达式(huangwenquan123)
获取到的html代码有多个select标签 我想获取

C# code
<select name="ProductsSearchLayout$BottomSectionPager$PagerLinksDropDownList" id="ProductsSearchLayout_BottomSectionPager_PagerLinksDropDownList" class="paginateDD" onChange="MM_jumpMenu('parent',this,0)">        <option selected="selected" value="/abella.aspx?avs=Brand%7cAbella&amp;fa=1">Page 1</option>     </select>

这个里面的option value 和Page 1怎么获取呢

[解决办法]

C# code
static void Main(string[] args)            {                string str = @"<select name=""ProductsSearchLayout$BottomSectionPager$PagerLinksDropDownList"" id=""ProductsSearchLayout_BottomSectionPager_PagerLinksDropDownList"" class=""paginateDD"" onChange=""MM_jumpMenu('parent',this,0)"">        <option selected=""selected"" value=""/abella.aspx?avs=Brand%7cAbella&amp;fa=1"">Page 1</option>     </select>";                              Regex re = new Regex(@"(?is)<select[^>]+id=""ProductsSearchLayout_BottomSectionPager_PagerLinksDropDownList""[^>]+>\s*<option[^>]+value=""([^""]+)"">([^<]+)</option>", RegexOptions.None);                Match ma = re.Match(str);                Console.WriteLine(ma.Groups[1].Value);  // 输出值为:/abella.aspx?avs=Brand%7cAbella&amp;fa=1                Console.WriteLine(ma.Groups[2].Value);  // 输出值为:Page 1                Console.ReadLine();            }
[解决办法]
回家在写下。还在公司处理事情。

热点排行