普通EX pression从网页解析链接? [英] Regular expression for parsing links from a webpage?

查看:182
本文介绍了普通EX pression从网页解析链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个.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]

这篇关于普通EX pression从网页解析链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆