Skip to content

Commit

Permalink
feature(string): Add split function
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrady committed Aug 30, 2020
1 parent ead33fc commit 102ea78
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@ function module.chop(str, suffix_query)
return s
end

-- Simple splitter function: divides a string into chunks based on the given delimeter.
function module.split(str, delim)
local chunks = {}
for chunk in str:gmatch('[^'..delim..']*') do
table.insert(chunks, chunk)
end
return chunks
end

-----------
return module

0 comments on commit 102ea78

Please sign in to comment.