<templatestyles src="Modul:Dokumentacija/styles.css"></templatestyles>
Dokumentacija modula[stvori]
local p = {}
function p.main(frame)
local title = mw.title.getCurrentTitle().text
local prefix = "Rezolucija Vijeća sigurnosti UN%-a"
local extracted_part, err = remove_prefix(title, prefix)
if extracted_part then
return(Wp100(tonumber(extracted_part))) -- Output: 1119
else
return("Error: " .. err)
end
end
function remove_prefix(s, prefix)
-- Use string.gsub to replace the prefix with an empty string
local result, count = string.gsub(s, "^" .. prefix, "")
-- Check if the prefix was found and removed
if count > 0 then
return result
else
return nil, "Prefix not found in the string."
end
end
function Wp100(number)
-- Calculate the lower bound of the range
local lower_bound = math.floor((number - 1) / 100) * 100 + 1
-- Calculate the upper bound of the range
local upper_bound = lower_bound + 99
-- Construct the link
local link = string.format("[[Dodatak:Popis rezolucija Vijeća sigurnosti UN-a od %d do %d]]", lower_bound, upper_bound)
return link
end
return p