FANDOM


(Undo revision 152519 by Capefeather (talk))
Line 6: Line 6:
 
function p.replace(frame)
 
function p.replace(frame)
 
text = frame.args[1]
 
text = frame.args[1]
return print(string.gsub(text, frame.args[2], "hello"))
+
return string.gsub(text, frame.args[2], "hello")
 
end
 
end
   

Revision as of 02:39, December 8, 2019

-- Simple find-and-replace that can be used on text templates so that there's less of a need for instances of nearly identical text.
-- Usage: {{#invoke:replace|replace|text|pattern to remove|pattern to insert}}
 
local p = {}
 
function p.replace(frame)
    text = frame.args[1]
    return string.gsub(text, frame.args[2], "hello")
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.