Split: Difference between revisions
Jump to navigation
Jump to search
(Added split() page) |
No edit summary |
||
| Line 10: | Line 10: | ||
When the separator is "", every character is split into a separate element. | When the separator is "", every character is split into a separate element. | ||
Split can be written without the use of parenthesis. | |||
== Examples == | == Examples == | ||
| Line 16: | Line 18: | ||
split("one:two:3",":",false) -- returns {"one","two","3"} | split("one:two:3",":",false) -- returns {"one","two","3"} | ||
split("1,,2,") -- returns {1,"",2,""} | split("1,,2,") -- returns {1,"",2,""} | ||
split "1,2,3" --returns {1,2,3} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 05:59, 5 June 2022
split( str, [separator,] [convert_numbers] )
- Split a string into a table of elements delimited by the given separator (defaults to ",").
- str
-
- The string.
- separator
-
- The separator (defaults to ",").
- convert_numbers
-
- When convert_numbers is true, numerical tokens are stored as numbers (defaults to true).
The split() function splits a string into a table of elements delimited by the given separator (defaults to ",").
Empty elements are stored as empty strings.
When the separator is "", every character is split into a separate element.
Split can be written without the use of parenthesis.
Examples
split("1,2,3") -- returns {1,2,3}
split("one:two:3",":",false) -- returns {"one","two","3"}
split("1,,2,") -- returns {1,"",2,""}
split "1,2,3" --returns {1,2,3}