Module:StringFunctions

local p = {}

function p.ListContains(frame) local CurrParamIndex = 1 local frameArgs = frame.args local delimiter = ',' local sourceList local searchArgs if (frameArgs["source"] ~= nil) then sourceList = frameArgs["source"] else sourceList = frameArgs[CurrParamIndex] CurrParamIndex = CurrParamIndex + 1 end if (frameArgs["search"] ~= nil) then searchArgs = frameArgs["search"] else searchArgs = frameArgs[CurrParamIndex] end

if (frameArgs["delimiter"] ~= nil) then delimiter = frameArgs["delimiter"] end for searchVal in string.gmatch(searchArgs,"[^"..delimiter.."]+") do		searchVal = searchVal:lower; if searchVal:sub(-1) == "*" then searchVal = searchVal:sub(1,-2) if (sourceList:find(searchVal,1,true) == nil) then return ''; end else local foundInList = false; for sourceVal in sourceList:gmatch("[^"..delimiter.."]+") do				if (sourceVal:lower == searchVal) then foundInList = true; break; end end if (foundInList == false) then return '' end; end end return '1'; end

function p.AbbValid(frame) local frameArgs = frame.args local tmpFrame = mw.getCurrentFrame local abbMode = 'text'; local abbSplit = ',' local abbCheckVals = frameArgs[1] if (frameArgs["abbMode"] ~= nil) then abbMode = frameArgs["abbMods"] end if (frameArgs["abbSplit"] ~= nil) then abbSplit = frameArgs["abbSplit"] end for abbVal in abbCheckVals:gmatch("[^"..abbSplit.."]+") do		local abbCheck = tmpFrame:expandTemplate{title='Abb',args={mode=abbMode,abbVal}} if (abbCheck == ) then return  end end return '1' end

return p