10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
['\xf3'] = '\3';
}
return {
capitalize = function(str)
return string.upper(string.sub(str, 1,1)) .. string.sub(str, 2)
end;
explode = function(str,delim)
local i = 1
local tbl = {}
repeat
local ss = string.sub(str, i)
local d = string.find(ss, delim, 1, true) or string.len(ss)+1
tbl[#tbl+1] = string.sub(ss,1,d-1)
i = i + d
until i > string.len(str)
return tbl
end;
rand = function(min,max)
if not min then min = 16 end
if not max then max = min end
|
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
|
<
>
|
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
['\xf3'] = '\3';
}
return {
capitalize = function(str)
return string.upper(string.sub(str, 1,1)) .. string.sub(str, 2)
end;
beginswith = function(str,pfx)
if #str < #pfx then return false end
return string.sub(str,1,#pfx) == pfx
end;
endswith = function(str,sfx)
if #str < #sfx then return false end
return string.sub(str,#sfx) == sfx
end;
explode = function(str,delim,pat) -- this is messy as fuck but it works so im keeping it
local i = 1
local tbl = {}
if pat == nil then pat = false end
repeat
local ss = string.sub(str, i)
local d
if pat then
local matches = {string.match(ss, '()' .. delim .. '()')}
if #matches > 0 then
local start,stop = matches[1], matches[#matches]
d = start
i = i + stop - 1
end
else
local dl = string.len(delim)
d = string.find(ss, delim, 1, not pat)
if d then i = i + d + dl - 1 end
end
if not d then
tbl[#tbl+1] = string.sub(ss,1,string.len(ss))
break
else
tbl[#tbl+1] = string.sub(ss,1,d-1)
end
until i > string.len(str)
return tbl
end;
rand = function(min,max)
if not min then min = 16 end
if not max then max = min end
|