【发布时间】:2017-01-18 10:38:50
【问题描述】:
我有这个字符串:
"<figure><img
src='http://myphotos.net/image.ashx?type=2&image=Images\\2\\9\\11\\12\\3\\8\\4\\7\\685621455625.jpg'
href='JavaScript:void(0);' onclick='return takeImg(this)'
tabindex='1' class='myclass' width='55' height='66' alt=\"myalt\"></figure>"
我怎样才能找回这个链接:
http://myphotos.net/image.ashx?type=2&image=Images\\2\\9\\11\\12\\3\\8\\4\\7\\685621455625.jpg
所有字符串都是相同的类型,所以我需要在 src= 和 href 之间获取子字符串。但我不知道该怎么做。谢谢。
【问题讨论】:
-
你可以使用 htmlagilitypack htmlagilitypack.codeplex.com 它在解析 html 方面做得很好。它通常比匹配正则表达式更稳定
-
字符引用 = '\'' ; string url=(thesourcestring+quote).split(quote)[1] ;
标签: c#