我在寻找一个.NET正EX pression提取网页中的所有网址,但还没有找到一个为COM prehensive足以涵盖所有你可以指定一个环节的不同方式。
I'm looking for a .NET regular expression extract all the URLs from a webpage but haven't found one to be comprehensive enough to cover all the different ways you can specify a link.
和侧面的问题:
有一正则表达式来统治他们所有?还是我最好使用一系列不太复杂的常规EX pressions,只是采用复式通过对原始的HTML? (速度与可维护性)
Is there 'one regex to rule them all'? Or am I better off using a series of less complicated regular expressions and just using mutliple passes against the raw HTML? (Speed vs. Maintainability)
((邮寄地址:|(新闻|(HT | F)TP(S)):/ /){1} S +)
((mailto:|(news|(ht|f)tp(s?))://){1}S+)
我把这个从 regexlib.com
[编者注:{1}在此正则表达式没有真正的功能; 看到这个帖子]
[editor's note: the {1} has no real function in this regex; see this post]