尝试更新 vimeo 正则表达式以从 URL 获取 ID,其中包括 "channels/staffpicks"
Trying to update a vimeo regex to get the ID from URL which includes "channels/staffpicks"
我有一个 vimeo 正则表达式,可以从标准 URL 获取 ID:https://vimeo.com/42100325
当 URL 为:https://vimeo.com/channels/staffpicks/142100325
时我无法使用它
这是我目前拥有的:
var vimeoId = /\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i;
尝试模式:
var vimeoId = /\/\/(?:www\.)?vimeo\.com\/(?:channels\/staffpicks\/)?([-\w]+)/i;
由于您只对末尾的部分感兴趣,因此没有理由在正则表达式中描述整个字符串:
var vimeoId = /([0-9a-z\-_]+)$/i;
我有一个 vimeo 正则表达式,可以从标准 URL 获取 ID:https://vimeo.com/42100325
当 URL 为:https://vimeo.com/channels/staffpicks/142100325
这是我目前拥有的:
var vimeoId = /\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i;
尝试模式:
var vimeoId = /\/\/(?:www\.)?vimeo\.com\/(?:channels\/staffpicks\/)?([-\w]+)/i;
由于您只对末尾的部分感兴趣,因此没有理由在正则表达式中描述整个字符串:
var vimeoId = /([0-9a-z\-_]+)$/i;