Vimeo 视频链接正则表达式

发布于 2024-10-17 19:41:59 字数 88 浏览 6 评论 0原文

有人得到了 vimeo 视频链接的正则表达式,可以从 pragraph 中提取它们以在 php 中使用吗?似乎无法找到适合最新 vimeo url 方案的合适方案

Anybody got the regex for vimeo video links to extract them from a pragraph for use in php? Can't seem to find a proper one for the latest vimeo url scheme

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

酷炫老祖宗 2024-10-24 19:41:59

Vimeo 有 4 个不同的公共视频链接

  1. 视频 ID vimeo.com/[Video ID]
  2. 频道 vimeo.com/channels/[Channel]/[Video ID]
  3. vimeo.com/groups/[组]/[视频 ID]
  4. 播放器 player.vimeo.com/video/[视频 ID]

/(http|https)?:\ /\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\ /|视频\/|)(\d+)(?:|\/\?)/

Vimeo have 4 different public video links

  1. Video ID vimeo.com/[Video ID]
  2. Channels vimeo.com/channels/[Channel]/[Video ID]
  3. Groups vimeo.com/groups/[Group]/[Video ID]
  4. Player player.vimeo.com/video/[Video ID]

/(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/

青巷忧颜 2024-10-24 19:41:59

这涵盖了所有可能的 Vimeo 视频 URL 方案:

(?:http|https)?:?\/?\/?(?:www\.)?(?:player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)
vimeo.com/123456789
vimeo.com/channels/mychannel/123456789
vimeo.com/groups/shortfilms/videos/123456789
player.vimeo.com/video/123456789
http://vimeo.com/123456789
https://vimeo.com/channels/mychannel/123456789
https://vimeo.com/groups/shortfilms/videos/123456789
https://www.player.vimeo.com/video/123456789

在此处测试
https://regexr.com/68gk3

This one covers all possible Vimeo Video URL Schemes:

(?:http|https)?:?\/?\/?(?:www\.)?(?:player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)
vimeo.com/123456789
vimeo.com/channels/mychannel/123456789
vimeo.com/groups/shortfilms/videos/123456789
player.vimeo.com/video/123456789
http://vimeo.com/123456789
https://vimeo.com/channels/mychannel/123456789
https://vimeo.com/groups/shortfilms/videos/123456789
https://www.player.vimeo.com/video/123456789

Test here:
https://regexr.com/68gk3

动次打次papapa 2024-10-24 19:41:59

据我所知,该方案只是 http://vimeo.com/A_NUMBER,因此请尝试 http://(www\.)?vimeo\.com/(\ d+)。如果您不需要以 http:// 为链接前缀,则可以省略整个 http://(www\.) 位。

As far as I can tell, the scheme is just http://vimeo.com/A_NUMBER, so try http://(www\.)?vimeo\.com/(\d+). If you don't need links to be prefixed by http://, you can leave off the whole http://(www\.) bit.

少年亿悲伤 2024-10-24 19:41:59

注意: url 方案例如

http://vimeo.com/[SEVERAL_FOLDERS(opt.)]/[VIDEO_NUMBER]

http://vimeo.com/channels/staffpicks/48237094
http://vimeo.com/48237094

如您所见,这取决于用户从哪个页面复制链接。

Be careful: The url scheme is

http://vimeo.com/[SEVERAL_FOLDERS(opt.)]/[VIDEO_NUMBER]

for example:

http://vimeo.com/channels/staffpicks/48237094
http://vimeo.com/48237094

As you can see, it depends from what page the user copies the link from.

茶花眉 2024-10-24 19:41:59

vimeo\.com/(\d)+ 有什么问题吗?您需要 http://www. 吗?

Is there anything wrong with vimeo\.com/(\d)+? Do you need the http://www.?

拥抱没勇气 2024-10-24 19:41:59

最好向 viemo 人员询问,因为他们更了解,如果他们更改任何内容,他们会在他们的 api

实时示例中反映它:

http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/76979871

API 文档:http://developer.vimeo.com/apis/oembed

受此启发的答案 https://stackoverflow.com/a/17156853/1545904

It's Better to ask viemo guys about it because they know better and if they change anything they will reflect it in their apis

Live Example :

http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/76979871

API docs : http://developer.vimeo.com/apis/oembed

Answer inspired from this one https://stackoverflow.com/a/17156853/1545904

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文