Difference between revisions of "Split"
Jump to navigation
Jump to search
(Created page with "<c>split</c> splits a string into a list, by some delimiter. See also: join === Arguments === {| class="wikitable" |- ! Parameter Name !! Default Value !! Meaning |- |...") |
|||
(One intermediate revision by one other user not shown) | |||
Line 11: | Line 11: | ||
| ''self'' || string || string to split | | ''self'' || string || string to split | ||
|- | |- | ||
− | | ''delimiter'' || string, default "" || substring to split on | + | | ''delimiter'' || string, default " " || substring to split on |
|- | |- | ||
| ''maxCount'' || number, default -1 || if > 0, split into no more than this many strings | | ''maxCount'' || number, default -1 || if > 0, split into no more than this many strings | ||
Line 21: | Line 21: | ||
== Example == | == Example == | ||
− | <ms>"foo bar baz".split // returns ["foo", "bar", "baz"] | + | <ms>"foo bar baz".split // returns ["foo", "bar", "baz"] |
+ | "foo bar baz".split("a", 2) // returns ["foo b", "r baz"]</ms> | ||
[[Category:Intrinsic Functions]] | [[Category:Intrinsic Functions]] | ||
[[Category:String Methods]] | [[Category:String Methods]] |
Latest revision as of 06:03, 14 October 2023
split
splits a string into a list, by some delimiter.
See also: join
Arguments
Parameter Name | Default Value | Meaning |
---|---|---|
self | string | string to split |
delimiter | string, default " " | substring to split on |
maxCount | number, default -1 | if > 0, split into no more than this many strings |
Usage Notes
split
may be called with function syntax or dot syntax.
Example
"foo bar baz".split // returns ["foo", "bar", "baz"]
"foo bar baz".split("a", 2) // returns ["foo b", "r baz"]