Call as
Functions.text.split(inputstr, sep)
Record it as a dependency named Functions.text.split (accepting the completion does this), then call it by that name.
Also accepted under the former namespace utils.
What it does
Split a string into nonempty runs between separator characters. The separator is inserted into a Lua pattern character class; it is not a literal multi-character delimiter. Empty fields are omitted.
Arguments
| Name | Type | What it does |
|---|---|---|
inputstr | string | Text to split. |
sep | string | nil | Lua pattern character-class separator, default %s for whitespace. |
Returns
| 1 | string[] | Dense array of nonempty text fields. |
|---|
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
It reads no game API directly.
Example
local parts = Functions.text.split("Fire,Frost,Arcane", ",")
return #parts == 3 and parts[2] == "Frost"Dependencies
string(builtin:utils.lua:string)
Source
Functions/text.lua, line 22. Read only in game; Duplicate makes an editable copy.
Functions.text.split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t