split
Shared
Splits a text into pieces at the separators.
table split(string text, string|int separator)
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The text. Only up to its first null byte counts. |
| separator | string|int | The characters that separate, or a character's code. |
Returns
A list with the pieces. Empty pieces are left out.
Example
local parts = split("2495.1,-1687.4,14.5", ",")
local x, y, z = tonumber(parts[1]), tonumber(parts[2]), tonumber(parts[3])NoteEach character of the separator splits on its own:
split("a, b", ", ") cuts at the comma and at the space.