跳转到内容

模組:Delcat

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由A2569875留言 | 贡献2018年2月5日 (一) 04:03 建立内容为“local p={ replace_data = { "%[%[[Cc][Aa][Tt].-%]%]", "%[%[分[類类].-%]%]", "%[%[[Cc]ategory.-%]%]", }, nullstr = '' } local strings = r…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)

local p={
	replace_data = { 
		"%[%[[Cc][Aa][Tt].-%]%]",
		"%[%[分[類类].-%]%]",
		"%[%[[Cc]ategory.-%]%]",
	},
	nullstr = ''
}
local strings = require( 'Module:String' )

--主函數
function p.main(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	get_args = getArgs(frame, {parentFirst=true})
	
	if get_args[0] ~= nil then return p.delete_category(get_args[0]) end
	if get_args['0'] ~= nil then return p.delete_category(get_args['0']) end
	return ''
end

function p.delete_category(source_str)
	local body = source_str
	for i, categorys in pairs( p.replace_data ) do
		body = mw.ustring.gsub( body, categorys, p.nullstr );	   
	end
	return body
end

return p