有兽档案馆
搜索
切换搜索
切换菜单
切换个人菜单
查看“Module:BilibiliVideoIDValidator”的源代码
来自有兽档案馆
阅读
查看源代码
查看历史
模块
讨论
更多操作
←
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 elseif string.len(id) == 10 then -- 若id为【1】开头时,当且仅当id长度为10位,且除去【1】后的部分均不包含小写l大写I、大写O和数字0时合法。 if not mw.ustring.match(id, '^1[a-km-zA-HJ-NP-Z0-9]+$') then result = false end elseif string.len(id) == 9 then -- 若id不满足上述四种情况时,当且仅当id长度为9位,且不包含小写l大写I、大写O和数字0时合法。 if not mw.ustring.match(id, '^[a-km-zA-HJ-NP-Z0-9]+$') then result = false end else result = false end else result = false end if result then return '' else return frame:expandTemplate {title = 'ArticleCategory', args = {'Bilibili视频ID错误'}} .. '<span class="BilibiliVideoIDValidatorArgument" style="display: none;">' .. frame.args.id .. '</span>' end end }
该页面使用的模板:
Template:ArticleCategory
(
查看源代码
)
Template:Documentation
(
查看源代码
)
Module:Arguments
(
查看源代码
)
Module:BilibiliVideoIDValidator
(
查看源代码
)
Module:BilibiliVideoIDValidator/doc
(
查看源代码
)
Module:Documentation
(
查看源代码
)
Module:Fullurl
(
查看源代码
)
Module:No globals
(
查看源代码
)
Module:Page name
(
查看源代码
)
Module:Yesno
(
查看源代码
)
返回
Module:BilibiliVideoIDValidator
。