mirror of
https://github.com/vxcontrol/soldr-modules.git
synced 2026-07-22 09:25:30 -04:00
24 lines
399 B
Lua
24 lines
399 B
Lua
local function split(str, pat)
|
|
local t = {}
|
|
local fpat = "(.-)" .. pat
|
|
local last_end = 1
|
|
local s, e, cap = str:find(fpat, 1)
|
|
|
|
while s do
|
|
if s ~= 1 or cap ~= "" then
|
|
table.insert(t,cap)
|
|
end
|
|
|
|
last_end = e + 1
|
|
s, e, cap = str:find(fpat, last_end)
|
|
end
|
|
|
|
if last_end <= #str then
|
|
cap = str:sub(last_end)
|
|
table.insert(t, cap)
|
|
end
|
|
|
|
return t
|
|
end
|
|
|
|
return split |