【问题标题】:C# regex get urlC# 正则表达式获取 url
【发布时间】:2015-05-20 16:30:17
【问题描述】:

我使用 C# 从 bing.com 获取一些网站。我使用了正则表达式:

MatchCollection list_rv_url = Regex.Matches(htmlCode, @"<cite>(?<Domain>[\w@][\w.:@]+)</cite>");

我只收到

www.example.com and example.com.

我想得到

http://example.com, https://example.com,http://www.example.com, https://www.example.com

感谢您的帮助!

【问题讨论】:

  • 提供您的输入字符串?
  • 从 bing.com bing.com/…阅读资源

标签: regex url get


【解决方案1】:

在匹配模式中包含/

Regex.Matches(htmlCode, @"<cite>(?<Domain>[\w@][\w.:@/]+)</cite>");
                                                     ^

【讨论】:

    猜你喜欢
    • 2011-09-30
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-11
    • 2011-03-27
    相关资源
    最近更新 更多