从包含多个PHP视频链接的字符串中获取第一个视频url(youtube、vimeo或dailymotion)

从包含多个PHP视频链接的字符串中获取第一个视频url(youtube、vimeo或dailymotion),php,regex,Php,Regex,我需要字符串中包含多个链接的第一个url(视频url可能是youtube、vimeo或dailymotion) 这是存储在$content变量中的我的内容 "Hello this is a test video<br>http://www.youtube.com/watch?v=wE7AQY5Xk9w<br>This is another test&nbsp;<br>http://www.youtube.com/watch?v=GqcqapoFy-w&

我需要字符串中包含多个链接的第一个url(视频url可能是youtube、vimeo或dailymotion)

这是存储在
$content
变量中的我的内容

"Hello this is a test video<br>http://www.youtube.com/watch?v=wE7AQY5Xk9w<br>This is another test&nbsp;<br>http://www.youtube.com/watch?v=GqcqapoFy-w<br>"
但是我得到了结果

array(
    (int) 0 => 'http://www.youtube.com/watch?v=wE7AQY5Xk9w<br>This',
    (int) 1 => 'http',
    (int) 2 => '/watch?v=wE7AQY5Xk9w<br>This'
)
数组(
(int)0=>'http://www.youtube.com/watch?v=wE7AQY5Xk9w
这",, (int)1=>“http”, (int)2=>'/watch?v=wE7AQY5Xk9w
此' )
在正则表达式模式中是否缺少任何东西

我使用的是PHP5.3.13


谢谢

我不确定你是否从上面的评论中得出了这个结论。。。但是,似乎你要用你的正则表达式走很长的路

您可以只使用:
/((http | https | ftp | ftps)[:=\w\.\/\?\-]+)/

其中将匹配以下URL:

http://www.dailymotion.com/video/x124dv4_8-month-old-deaf-baby-hears-for-the-first-time_fun#.Ueu0YuEju1E
http://www.youtube.com/watch?v=wE7AQY5Xk9w
http://vimeo.com/channels/staffpicks/67576646
http://www.youtube.com/watch?v=GqcqapoFy-w
在本文中:

Hello http://www.dailymotion.com/video/x124dv4_8-month-old-deaf-baby-hears-for-the-first-time_fun#.Ueu0YuEju1E this is a test video<br>http://www.youtube.com/watch?v=wE7AQY5Xk9w<br>This is another http://vimeo.com/channels/staffpicks/67576646 test&nbsp;<br>http://www.youtube.com/watch?v=GqcqapoFy-w<br>
你好http://www.dailymotion.com/video/x124dv4_8-month-old-deaf-baby-hears-for-the-first-time_fun#.Ueu0YuEju1E 这是一段测试视频
http://www.youtube.com/watch?v=wE7AQY5Xk9w
这是另一个问题http://vimeo.com/channels/staffpicks/67576646 测试
http://www.youtube.com/watch?v=GqcqapoFy-w

你认为
\S*
是什么意思?我认为它也指所有包含
的字符串。如果youtube url类似于
。这个问题不会发生(ID后面的空格)。“我想它意味着所有字符串”--不猜测而是检查文档怎么样?
Hello http://www.dailymotion.com/video/x124dv4_8-month-old-deaf-baby-hears-for-the-first-time_fun#.Ueu0YuEju1E this is a test video<br>http://www.youtube.com/watch?v=wE7AQY5Xk9w<br>This is another http://vimeo.com/channels/staffpicks/67576646 test&nbsp;<br>http://www.youtube.com/watch?v=GqcqapoFy-w<br>