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

求正则,匹配href属性值(下面四类地址),确保准确,高分!该如何解决

2012-02-04 
求正则,匹配href属性值(下面四类地址),确保准确,高分!!aid myhref index.html title click Clic

求正则,匹配href属性值(下面四类地址),确保准确,高分!!
<a   id= 'my '   href= "index.html "   title= "click "> Click </a>
<a   id= 'my '   href= 'index.html '   title= "click "> Click </a>
<a   id= 'my '   href=index.html   title= "click "> Click </a>

带空格的地址
<a   id= 'my '   href= "index   2.html "   title= "click "> Click </a>




[解决办法]
于娜小姐好高的分

[解决办法]
样本
<a id= 'my ' href= "index.html " title= "click "> Click </a>
<a id= 'my ' href= 'index.html ' title= "click "> Click </a>
<a id= 'my ' href=index.html title= "click "> Click </a>
<a id= 'my ' href= "index 2.html " title= "click "> Click </a>

正则
href=(([ "| ']{1})[\w\. ]+(\2)|([\w\.]+))

结果
href= "index.html " is match
Group[0]=href= "index.html "
Group[1]= "index.html "
Group[2]= "
Group[3]= "
Group[4]=
href= 'index.html ' is match
Group[0]=href= 'index.html '
Group[1]= 'index.html '
Group[2]= '
Group[3]= '
Group[4]=
href=index.html is match
Group[0]=href=index.html
Group[1]=index.html
Group[2]=
Group[3]=
Group[4]=index.html
href= "index 2.html " is match
Group[0]=href= "index 2.html "
Group[1]= "index 2.html "
Group[2]= "
Group[3]= "
Group[4]=


热点排行