mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Removed lua_utils split function
This commit is contained in:
parent
c73cfb9d27
commit
fd57de106c
1 changed files with 17 additions and 26 deletions
|
|
@ -553,32 +553,23 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function split(pString, pPattern)
|
||||
local Table = {} -- NOTE: use {n = 0} in Lua-5.0
|
||||
local fpat = "(.-)" .. pPattern
|
||||
local last_end = 1
|
||||
|
||||
-- input check
|
||||
if pString == nil then
|
||||
return Table
|
||||
end
|
||||
if type(pString) ~= "string" then
|
||||
pString = tostring(pString)
|
||||
end
|
||||
|
||||
local s, e, cap = pString:find(fpat, 1)
|
||||
while s do
|
||||
if s ~= 1 or cap ~= "" then
|
||||
table.insert(Table,cap)
|
||||
end
|
||||
last_end = e+1
|
||||
s, e, cap = pString:find(fpat, last_end)
|
||||
end
|
||||
if last_end <= #pString then
|
||||
cap = pString:sub(last_end)
|
||||
table.insert(Table, cap)
|
||||
end
|
||||
return Table
|
||||
-- split
|
||||
function split(s, delimiter)
|
||||
result = {};
|
||||
if(s ~= nil) then
|
||||
if delimiter == nil then
|
||||
-- No delimiter, split all characters
|
||||
for match in s:gmatch"." do
|
||||
table.insert(result, match);
|
||||
end
|
||||
else
|
||||
-- Split by delimiter
|
||||
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
|
||||
table.insert(result, match);
|
||||
end
|
||||
end
|
||||
end
|
||||
return result;
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue