查看“Module:BilibiliVideoIDValidator”的源代码
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您可以查看和复制此页面的源代码。
return {
validation = function(frame)
local result = true
local id = mw.text.trim(frame.args.id or '')
if mw.ustring.match(id, '^%d+$') then
-- 纯数字
if not (string.sub(id, 1, 1) ~= '0' and string.len(id) <= 9) then -- 若id为纯数字时,当首位不为0且长度在1-9位时合法。
result = false
end
elseif mw.ustring.match(id, '^[aA][vV]%d+$') then
-- 若id为【av+纯数字】(不区分大小写)时,当且仅当纯数字部分首位不为0且长度在1-9位时合法,其余情况添加分类
if not (string.sub(id, 3, 3) ~= '0' and string.len(id) <= 11) then
result = false
end
elseif mw.ustring.match(id, '4.1.7..$') then
if string.len(id) == 12 then
-- 若id为【BV1】开头时,当且仅当id长度为12位,且除去【BV1】后的部分均不包含小写l大写I、大写O和数字0时合法。
if not mw.ustring.match(id, '^[bB][vV]1[a-km-zA-HJ-NP-Z0-9]+$') then
result = false
end
000
1:0
本页使用的模板: