Module:Replace

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search

local p = {}

function p.main(frame)
    local args = frame:getParent().args
    local haystack = args[1] or ""
    local needle = args[2] or ""
    local replacement = args[3] or ""

    haystack = tostring(haystack)
    needle = tostring(needle)
    replacement = tostring(replacement)

    local result = haystack:gsub(needle, replacement)

    return result
end

return p