-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper.lua
More file actions
41 lines (31 loc) · 861 Bytes
/
helper.lua
File metadata and controls
41 lines (31 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
local helper = {}
function helper.stringSplit(szFullString, szSeparator)
local nFindStartIndex = 1
local nFindLastIndex
local nSplitIndex = 1
local nSplitArray = {}
local size = string.len(szFullString)
while true do
local i, j = string.find(szFullString, szSeparator, nFindStartIndex)
if not i then
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, size)
break
end
nFindLastIndex = j
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)
nFindStartIndex = nFindLastIndex + 1
nSplitIndex = nSplitIndex + 1
end
return nSplitArray
end
-- check string is empty
function helper.stringIsEmpty(str)
if not str or str == '' then
return true
end
if string.find(str, "[^%s]") then
return false
end
return true
end
return helper