20.643
Bearbeitungen
K (Entfernte den Schutz von „Modul:String“) |
(+ appendWithComma(s, a)) |
||
| (8 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 49: | Zeile 49: | ||
-- Removes all spaces at the start and at the end of a string | -- Removes all spaces at the start and at the end of a string | ||
return s:match("^%s*(.-)%s*$") | return s:match("^%s*(.-)%s*$") | ||
end | |||
function p.nilStrip(s) | |||
-- same as p.strip(s), but removes nil, if s is empty or nil | |||
-- useful to handle missing/empty args | |||
if s == nil then | |||
return | |||
end | |||
s = p.strip(s) | |||
if s == "" then | |||
return | |||
end | |||
return s | |||
end | end | ||
| Zeile 68: | Zeile 81: | ||
-- if list has no content, table will be empty | -- if list has no content, table will be empty | ||
delimiter = delimiter or " " | delimiter = delimiter or " " | ||
s = s .. delimiter | s = (s or "") .. delimiter | ||
local result = {} | local result = {} | ||
local start = 1 | local start = 1 | ||
| Zeile 105: | Zeile 118: | ||
end | end | ||
return s_pre_bracket, s, s_post_bracket | return s_pre_bracket, s, s_post_bracket | ||
end | |||
function p.appendWithComma(s, a) | |||
if a ~= nil and a ~= "" then | |||
if s ~= "" then | |||
s = s .. ", " .. a | |||
else | |||
s = a | |||
end | |||
end | |||
return s | |||
end | end | ||
return p | return p | ||