Lua – code to split string into lines based on carriage return and newlines


function SplitMeIntolines(str)
local t = {}
local function helper(line) table.insert(t, line) return "" end
helper((str:gsub("(.-)r?n", helper)))
return t
end

5 Replies to “Lua – code to split string into lines based on carriage return and newlines”

  1. It is missing some backslashes, right?
    function SplitMeIntolines(str)
    local t = {}
    local function helper(line) table.insert(t, line) return “” end
    helper((str:gsub(“(.-)\r?\n”, helper)))
    return t
    end

Leave a Reply

Your email address will not be published.