我想从一个纯文本字符串在PHP中提取一个或多个网址。下面是一些例子从一个字符串提取一个或多个网址在php
"mydomain.com has hit the headlines again"
提取物 “http://www.mydomain.com”
"this is 1 domain.com and this is anotherdomain.co.uk but sometimes http://thirddomain.net"
提取物 “http://www.domain.com”, “http://www.anotherdomain.co.uk”, “http://www.thirddomain.net”
有两种特殊情况下,我需要的 - 我想正则表达式,但不完全了解它们
1)需要删除像'('或')'和空格(不包括连字符)的所有符号
)字点需要用符号替换。 ,所以网络com将.com .com
p.s我知道PHP validation/regex for URL,但不能解决我将如何使用它来实现最终目标。
谢谢
'mydomain.com = HTTP:// www.mydomain.com' – NikiC 2010-11-06 09:36:52