split string||doc136030

September 20, 2022

Format

 Lib.splitString(str, sep, to_number) 
  • The class to which the function belongs:Lib

Description

Split the string content according to characters.


Parameters

Variable name type Description
str string string
sep string separator
to_number boolean Whether to force the number


Value Returned

type Description
table table of delimited content


Code Samples

local str = "1,2,3,4,5"
local array = Lib.splitString(str, ",", true)
for _, s in pairs(array) do
    print(s)
end
-- Output:1, 2, 3, 4, 5