Better variable names
This commit is contained in:
parent
6e3966fe24
commit
34b0c6737e
|
@ -942,25 +942,25 @@ end
|
||||||
|
|
||||||
--- Splits a string in a table
|
--- Splits a string in a table
|
||||||
--
|
--
|
||||||
-- @tparam string pString The string to split
|
-- @tparam string string_to_split The string to split
|
||||||
-- @tparam string pPattern At which character/pattern to split the string
|
-- @tparam string pattern At what character/pattern to split the string
|
||||||
-- @treturn table A table containing the splitted strings.
|
-- @treturn table A table containing the splitted strings.
|
||||||
-- @usage args = textutils.splitString("arg1 arg2", " ")
|
-- @usage args = textutils.splitString("arg1 arg2", " ")
|
||||||
-- @since edit this if it goes live (I hope it does)
|
-- @since edit this if it goes live (I hope it does)
|
||||||
function splitString(pString, pPattern)
|
local function split(string_to_split, pattern)
|
||||||
local Table = {}
|
local Table = {}
|
||||||
local fpat = "(.-)" .. pPattern
|
local fpat = "(.-)" .. pattern
|
||||||
local last_end = 1
|
local last_end = 1
|
||||||
local s, e, cap = pString:find(fpat, 1)
|
local s, e, cap = string_to_split:find(fpat, 1)
|
||||||
while s do
|
while s do
|
||||||
if s ~= 1 or cap ~= "" then
|
if s ~= 1 or cap ~= "" then
|
||||||
table.insert(Table, cap)
|
table.insert(Table, cap)
|
||||||
end
|
end
|
||||||
last_end = e + 1
|
last_end = e + 1
|
||||||
s, e, cap = pString:find(fpat, last_end)
|
s, e, cap = string_to_split:find(fpat, last_end)
|
||||||
end
|
end
|
||||||
if last_end <= #pString then
|
if last_end <= #string_to_split then
|
||||||
cap = pString:sub(last_end)
|
cap = string_to_split:sub(last_end)
|
||||||
table.insert(Table, cap)
|
table.insert(Table, cap)
|
||||||
end
|
end
|
||||||
return Table
|
return Table
|
||||||
|
|
Loading…
Reference in New Issue