Skip to content

Instantly share code, notes, and snippets.

@cl4u2
Created September 11, 2014 14:55
Show Gist options
  • Save cl4u2/518c96b7e34af458ded6 to your computer and use it in GitHub Desktop.
Save cl4u2/518c96b7e34af458ded6 to your computer and use it in GitHub Desktop.
Delete first n lines of a string
function del_first_lines(astring, n)
-- parameters: string and number of initial lines to be deleted
local result = ""
local deleted = n
local newfirst = true
for line in astring:gmatch("[^\r\n]+") do
if deleted > 0 then
deleted = deleted - 1
else
if newfirst then
result = result .. line
newfirst = false
else
result = result .. "\n" .. line
end
end
end
return result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment