From e7dcbd5a9541f24bb3ffd712d26303e683c953fe Mon Sep 17 00:00:00 2001 From: sammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 1 May 2021 01:08:20 -0400 Subject: [PATCH] feat: add string.split function --- preload.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/preload.lua b/preload.lua index a5d087f..2776122 100644 --- a/preload.lua +++ b/preload.lua @@ -65,3 +65,22 @@ do end end) end + +-- Function additions to Lua standard library +function string.split(str, delimiter) + local result = {} + local from = 1 + + local delim_from, delim_to = string.find(str, delimiter, from) + + while delim_from do + table.insert(result, string.sub(str, from, delim_from - 1)) + from = delim_to + 1 + delim_from, delim_to = string.find(str, delimiter, from) + end + + table.insert(result, string.sub(str, from)) + + return result +end +