我想从给定文本中解析 URL,
输入文本:-
<h3 class="r"> <a
href="/url?q=http://rakesh.agrawal-family.com/papers/vldbj03watermark.pdf&sa=U&ei=m2laUfD2AdDorQf0rYHoDw&ved=0CBoQFjAA&usg=AFQjCNFJOQCS471sWjxy5CkNbzDxzcD66A">
<h3 class="r"> <a
href="/url?q=http://www.cse.ust.hk/vldb2002/VLDB2002-proceedings/papers/S05P03.pdf&sa=U&ei=m2laUfD2AdDorQf0rYHoDw&ved=0CCIQFjAD&usg=AFQjCNHbfCk_51dKLupvs3KVVEDboK54xg">
<h3 class="r"> <a
href="/url?q=http://cvml.unige.ch/publications/postscript/99/VoloshynovskiyPereiraPun_eww99.pdf&sa=U&ei=m2laUfD2AdDorQf0rYHoDw&ved=0CCYQFjAE&usg=AFQjCNGt54TSNY93PXgd4u4L3-E6C6P2jw">
预期输出:
http://rakesh.agrawal-family.com/papers/vldbj03watermark.pdf
http://www.cse.ust.hk/vldb2002/VLDB2002-proceedings/papers/S05P03.pdf
http://cvml.unige.ch/publications/postscript/99/VoloshynovskiyPereiraPun_eww99.pdf
示例代码:-
Match match = Regex.Match(input, @"<h3 class=""r""> <a href=""/url\?q=(.*?)&", RegexOptions.IgnoreCase);
while (match.Success)
{
// Finally, we get the Group value and display it.
string key = match.Groups[1].Value;
Console.WriteLine(key);
match = match.NextMatch();