可能重复:
Identifying if a URL is present in a string
Php parse links/emailsPHP:正则表达式从字符串获取URL
我工作的一些PHP代码这需要从各种来源和投入需要找到这些URL并将它们保存在某个地方。需要处理的类型的输入如下:
http://www.youtube.com/watch?v=IY2j_GPIqRA
Try google: http://google.com! (note exclamation mark is not part of the URL)
Is http://somesite.com/ down for anyone else?
输出:
http://www.youtube.com/watch?v=IY2j_GPIqRA
http://google.com
http://somesite.com/
我已经从工作,但不幸的是互联网借一个正则表达式抹查询串出- 不好!
任何帮助把一个正则表达式,或者可能是另一个解决方案,这个问题,将不胜感激。