ElEditors, Administrators
70,698
edits
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
for k, v in pairs(array) do | for k, v in pairs(array) do | ||
if string.find(k, key) then | if string.find(k, key) then | ||
return true | |||
end | |||
end | |||
end | |||
function inArrayHasValue(value, array) | |||
for k, v in pairs(array) do | |||
if string.find(v, value) then | |||
return true | return true | ||
end | end | ||
Line 84: | Line 92: | ||
-- Implement splitting string to a table. | -- Implement splitting string to a table. | ||
function split(s, delimiter) | function split(s, delimiter, skip_empty) | ||
if not s then | if not s then | ||
return {} | return {} | ||
Line 94: | Line 102: | ||
result = {}; | result = {}; | ||
for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do | for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do | ||
table.insert(result, i, trim(match)); | if (skip_empty == true and trim(match) ~= '') or skip_empty == nil then | ||
table.insert(result, i, trim(match)); | |||
i = i + 1 | |||
end | |||
end | end | ||
return result; | return result; |