string.split

Splits a string into a table, matching on specific delimiters.

Usage

string.split(my_string, delimiters)

Arguments

Name Type Description
my_string string String to split.
delimiters string String whose individual characteres are used as delimiters.

Returns

Name Type Description
split_result table List of components after the split.

Examples

local sentence = "Welcome to my shop, adventurer!";
local words = sentence:split(" ,!");
for _, word in ipairs(words) do
  -- Sequentially prints "welcome", "to", "my", "shop" and "adventurer"
  print(word);
end

This site uses Just the Docs, a documentation theme for Jekyll.