Module:CommonFunctions: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 60: Line 60:
-- Implement splitting string to a table.
-- Implement splitting string to a table.
function split(s, delimiter)
function split(s, delimiter)
    local i = 1
     if delimiter == nil then delimiter = ',' end
     if delimiter == nil then delimiter = ',' end
     result = {};
     result = {};
     for match in (s..delimiter):gmatch("(.-)"..delimiter) do
     for match in (s..delimiter):gmatch("(.-)"..delimiter) do
         table.insert(result, match);
         table.insert(result, match, i);
        i = i + 1
     end
     end
     return result;
     return result;