【发布时间】:2012-03-01 13:45:28
【问题描述】:
【问题讨论】:
-
这里有一个非常相似的线程:stackoverflow.com/questions/965893/…
标签: c# string windows-phone-7 rss
【问题讨论】:
标签: c# string windows-phone-7 rss
如果这真的是全部你有你可能摆脱正则表达式,如
src="([^"]+)
但是,您不能也不应该尝试使用正则表达式解析 HTML。 Using regular expressions to parse HTML: why not?
请改用 Html Agility Pack 之类的 HTML 解析器。不过,我不知道它是否适用于 WP7。
【讨论】:
使用正则表达式的完整解决方案:
string source ="<img src=\"http://MyUrl.JPG.jpg\"";
var reg = new Regex("src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?");
var match=reg.Match(source);
if(match.Success)
{
var encod = match.Groups["imgSrc"].Value;
}
【讨论】: