Splits a string based on another seperator string. Also available as string.split (though not provided by the Lua standard library).


See also Utility functions.

Signature:

... = strsplit("sep", "text", limit)

Arguments:

  • sep - The seperator string to use (string)
  • text - The text to split (string)
  • limit - The maximum number of pieces to split the string into (number)

Returns:

  • ... - A list of strings, split from the input text based on the seperator string (string)

Examples:

-- Split the string "a:b:c:d"
strsplit(":", "a:b:c:d", 2)
-- Returns "a", "b:c:d"

-- Split the string "a::b::c::d"
strsplit("::", "a::b::c::d")
-- Returns "a", "b", "c", "d"