sonic-radiance/sonic-radiance.love/birb/utils/string.lua

26 lines
612 B
Lua
Raw Normal View History

2021-03-22 15:54:17 +01:00
local String = {}
function String.isEmpty(pString)
return (pString == "" or pString == nil)
end
function String.split(pString, pPattern)
local Table = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pPattern
local last_end = 1
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
2021-08-31 10:57:24 +02:00
end
2021-03-22 15:54:17 +01:00
return String