Php 我';我用这个preg_替换代码来嵌入视频有问题吗?

Php 我';我用这个preg_替换代码来嵌入视频有问题吗?,php,iframe,preg-replace,embed,Php,Iframe,Preg Replace,Embed,我正在尝试直接从链接嵌入视频 链接示例 https://www.example.com/video22818393/dancing_with_the_moon 标准嵌入代码: <iframe src="https://www.example.com/embedframe/22818393" frameborder=0 width=510 height=400 scrolling=no allowfullscreen=allowfullscreen></iframe>

我正在尝试直接从链接嵌入视频

链接示例

https://www.example.com/video22818393/dancing_with_the_moon
标准嵌入代码:

<iframe src="https://www.example.com/embedframe/22818393" frameborder=0 width=510 height=400 scrolling=no allowfullscreen=allowfullscreen></iframe>

直接从链接嵌入视频的我的代码:

$post[message] = preg_replace('/<a href="https?:\/\/www\.example\.com\/video([a-z0-9A-Z]+)\/([a-z0-9A-Z]+)" target="_blank">(.+?)<\/a>/', '<iframe src="https://www.example.com/embedframe/$1" frameborder=0 width=510 height=400 scrolling=no allowfullscreen=allowfullscreen></iframe>', $post[message]);
$post[message]=preg_replace(“/(.+?)/”,“$post[message]);

但是使用此代码只需显示站点链接而不是视频,这样任何人都知道我做错了什么?

将最后一个
([a-z0-9A-Z]+)
替换为
([^\/]+)
,使用
“~”
谢谢你的建议@WiktorStribiżew,我试过了,但不起作用。这正是你需要的视频数量吗?它确实起作用,请参见将最后一个
([a-z0-9A-Z]+)
替换为
([^\/]+)
,使用
“~~”
谢谢您的建议@WiktorStribiżew,我试过了,但它不起作用。这正是您需要的视频数量吗?它确实起作用,请参见