20.636
Bearbeitungen
(splitAndStrip() nil handling) |
(+ p.nilStrip()) |
||
| 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 | ||