如何解析HTML/XML并从中提取信息?
可能重复:
识别字符串中是否存在URL
Php解析链接/电子邮件
我正在研究一些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?
Run Code Online (Sandbox Code Playgroud)
输出:
http://www.youtube.com/watch?v=IY2j_GPIqRA
http://google.com
http://somesite.com/
Run Code Online (Sandbox Code Playgroud)
我已经从互联网借用了一个正则表达式,但不幸的是擦掉了查询字符串 - 不好!
任何帮助组合正则表达式,或者可能是这个问题的另一种解决方案,将不胜感激.