Module:CheckUser requests at UTRS: Difference between revisions

Content deleted Content added
oops
tostring not needed
 
(One intermediate revision by the same user not shown)
Line 2:
 
function p.main()
local UTRS = mw.title.new('User:AmandaNP/UTRS Appeals').content -- get the UTRS table
local numberEncountered = 0 -- initialize the counter
local currentStartIndex = 1 -- initialize the index
 
while true do
-- find the next occurrence of 'CHECKUSER'
local nextMatchRange = string.find(UTRS, 'CHECKUSER', currentStartIndex, true)
if not nextMatchRange then
 
-- no more occurrences found, return the count
if not nextMatchRange then
return tostring(numberEncountered)
-- no more occurrences found, return the count
else
return tostring(numberEncountered)
-- found a match, so increment the counter and update the current start index
else
numberEncountered = numberEncountered + 1
-- found a match, so increment the counter and update the current start index
currentStartIndex = nextMatchRange + 1 -- move past the current match
numberEncountered = numberEncountered + 1
end
currentStartIndex = nextMatchRange + 1 -- move past the current match
end
end
end