【发布时间】:2012-10-11 18:46:57
【问题描述】:
$message = "this is an youtube video http://www.youtube.com/watch?v=w6yF_UV1n1o&feature=fvst i want only the id";
$message = preg_replace('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', '\\1', $message);
print $message;
上面的打印...
this is an youtube video http://www.w6yF_UV1n1o&feature=fvst i want only the id
我想要的是:
this is an youtube video w6yF_UV1n1o i want only the id
提前感谢:)
【问题讨论】:
-
我不想只解析一个 URL 我想解析整条消息,这是一个 vBulletin 板,所以用户只粘贴一个链接,YouTube 视频就会神奇地出现 :)
标签: php regex parsing youtube preg-replace