从任何字符串中提取任何URL? [英] Extract any URL from any string?

查看:74
本文介绍了从任何字符串中提取任何URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

geturl.php


要粘贴的代码太多了,但看看 http://www.liarsscourge.com/

到目前为止,我还没有发现可以破解这个字符串的字符串...


任何内置功能或改进建议?


提前致谢。

解决方案

2月10日晚上8:41,deko < d ... @nospam.comwrote:


geturl.php


要粘贴的代码太多了,但是看看http://www.liarsscourge.com/


到目前为止,我还没有发现可以打破这个的字符串...


任何内置功能或改进建议?


提前致谢。



我不想在这里听起来很消极,但具体到底是什么意思?

我问的原因是因为我看不出你为什么不能用一个正则表达式提取它的原因

然后你可以用另一个来验证它。
验证它。这很简单,验证,问题是如何有效

你想要它。如果您需要指定每个TLD,或者您是否需要匹配模式。在任何一种情况下,2或3个正则表达式

max应该能够完成你所追求的目标。通过一些额外的工作,您可以一次性提取多个URL。


deko写道:


geturl.php


要粘贴的代码太多,但看看
http://www.liarsscourge.com/

到目前为止,我没有找到一个可以打破这个的字符串...


任何内置函数或改进建议?



1。增加error_reporting级别你会发现一些草率的通知

2.看看parse_url(),它可能很有用

3.使用preg_ *函数而不是POSIX ereg * function(性能)

4.以下字符串会导致无限循环:


getURL(''fofo http://discovery.co.uk /../foo'');


可能修复:


=替换:


如果(!是的GI(" ^(COM |净|组织...)


",

geturl.php

Too much code to paste here, but have a look at http://www.liarsscourge.com/

So far, I have not found a string that can break this...

Any built-in functions or suggestions for improvement?

Thanks in advance.

解决方案

On Feb 10, 8:41 pm, "deko" <d...@nospam.comwrote:

geturl.php

Too much code to paste here, but have a look athttp://www.liarsscourge.com/

So far, I have not found a string that can break this...

Any built-in functions or suggestions for improvement?

Thanks in advance.


I don''t want to sound negative here, but what exactly is the point?
The reason I ask, is because I see no reason why you can''t extract it
with a single regex expression, and then you could use another one to
validate it. It''s simple enough to validate, the question is how valid
do you want it to be. Should you need to specify each TLD, or do you
just need to match a pattern. In either case, 2 or 3 regex expressions
max should be able to do what you are after. With a little extra
crafting, you should be able to extract multiple URLs in one go.


deko wrote:

geturl.php

Too much code to paste here, but have a look at
http://www.liarsscourge.com/
So far, I have not found a string that can break this...

Any built-in functions or suggestions for improvement?

1. Increase the error_reporting level and you will find some sloppy notices
2. Have a look at parse_url(), which might be useful
3. Use preg_* functions instead of POSIX ereg* function (performance)
4. Strings like the following cause infinite loops:

getURL(''fofo http://discovery.co.uk/../foo'');

Probable fix:

= Replace:

if (!eregi("^(com|net|org...)


",


这篇关于从任何字符串中提取任何URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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