我有一个文本或消息。
我们的要求是获得来自text.We链接使用下面的代码
List<string> list = new List<string>();
Regex urlRx = new
Regex(@"(?<url>(http:|https:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)",
RegexOptions.IgnoreCase);
MatchCollection matches = urlRx.Matches(message);
foreach (Match match in matches)
{
list.Add(match.Value);
}
return list;
它给的网址,但不是代码的完整one.Output是
但是我们需要完整的网址,如
请建议如何解决issue.Thanks提前。
看看这个[stackoverflow](http://stackoverflow.com/questions/2343177/regex-for-url-including-query-string)的问题,我相信它会解决你的问题。 – Bibhu 2012-02-03 07:24:53
查看[这个页面](http://daringfireball.net/2010/07/improved_regex_for_matching_urls)获得一个完整的正则表达式,用于在reguler文本中查找和隐藏URL。如果你需要更简单的东西,我认为它的评论足够好,你应该能够适应你的具体情况。 – 2012-02-03 07:22:35