Modul:Gsub
Erscheinungsbild
Modul:Vorlage:LuaModuleDoc:144: attempt to index field 'wikibase' (a nil value)
Datei:Template superseded.svg Dieses Modul ist veraltet.
Bitte verwende stattdessen Modul:Str, im Speziellen:
{{#invoke:Gsub|HTMLspaces|text}}→{{#invoke:Str|replace|text| |%20}}(oder{{urlencode:text|PATH}}){{#invoke:Gsub|subst|text|pattern|replace}}→{{#invoke:Str|replace|text|pattern|replace||ja}}
local Gsub = {}
-- Substitute all spaces to HTML hex code
function Gsub.HTMLspaces(frame)
local result = ""
local n = 0 -- number of replacements
-- replace now, we MUST fetch the number of replacements!
-- Otherwise we will get unpredicted result
result, n = mw.ustring.gsub(frame.args[1], " ", "%%20")
if (n == 0) then return frame.args[1] end
return result
end
-- replace all pattern in text by replace
function Gsub.subst(frame)
local text = frame.args[1] or ""
local pattern = frame.args[2] or ""
local replace = frame.args[3] or ""
local result = ""
local n = 0 -- number of replacements
if (text == "") then return "" end
if (pattern == "" or replace == "") then return text end
-- replace now, like above
result, n = mw.ustring.gsub(text, pattern, replace)
if (n == 0) then return text end
return result
end
return Gsub