mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-03 10:23:50 +00:00
Fix. Add split function (required by lazy_settings).
This commit is contained in:
27
resources/install/scripts/resources/functions/split.lua
Normal file
27
resources/install/scripts/resources/functions/split.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
function split(str, sep, plain)
|
||||
local b, res = 1, {}
|
||||
while b <= #str do
|
||||
local e, e2 = string.find(str, sep, b, plain)
|
||||
if e then
|
||||
res[#res + 1] = string.sub(str, b, e-1)
|
||||
b = e2 + 1
|
||||
else
|
||||
res[#res + 1] = string.sub(str, b)
|
||||
break
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
function split_first(str, sep, plain)
|
||||
local e, e2 = string.find(str, sep, nil, plain)
|
||||
if e then
|
||||
return string.sub(str, 1, e - 1), string.sub(str, e2 + 1)
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
local unpack = unpack or table.unpack
|
||||
|
||||
function usplit(...) return unpack(split(...)) end
|
||||
|
||||
Reference in New Issue
Block a user