From 102ea7843fee9ffd61ecad09bf72c4144f82b04c Mon Sep 17 00:00:00 2001 From: Daniel Brady Date: Sun, 30 Aug 2020 13:17:01 -0400 Subject: [PATCH] feature(string): Add `split` function --- string.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/string.lua b/string.lua index e435e1b..c084a59 100644 --- a/string.lua +++ b/string.lua @@ -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