Str.split

From OpenEUO
Revision as of 19:25, 11 November 2010 by Ximan (Talk | contribs) (Created page with "== Calling Pattern == Call local r = sl.str.split(source,n[,...]) Args source is a string n1...nN are numbers Results r is a table of strings == Usage Example == local s =...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Calling Pattern

Call

local r = sl.str.split(source,n[,...])

Args

source is a string
n1...nN are numbers

Results

r is a table of strings

Usage Example

local s = sl.str
local r = s.split('One really long string.',2,7,11)
print(sl.keyvalstr(r))
--> O
--> ne re
--> ally
-->  long string.

Description

Split separates the source string into parts and returns them in a table. Each number n passed is treated as a position at which to split the string.

Upon Error

Split fails silently. If split receives inappropriate arguments then a table with a single empty string is returned. If a non-number is passed as one of the position arguments, then an empty string is inserted in the resulting table for that position.

See Also