mirror of
https://github.com/Hilbis/Hilbish
synced 2025-04-02 19:53:23 +00:00
feat: add string.split function
This commit is contained in:
parent
507c8b6ed2
commit
e7dcbd5a95
19
preload.lua
19
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user