Difference between revisions of "Split"

From MiniScript Wiki
Jump to navigation Jump to search
 
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

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"]