Difference between revisions of "Split"

From MiniScript Wiki
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 |- |...")
 
Line 21: Line 21:
 
== Example ==
 
== Example ==
  
<ms>"foo bar baz".split // returns ["foo", "bar", "baz"]         "foo bar baz".split("a", 2) // returns ["foo b", "r baz"]</ms>
+
<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]]

Revision as of 03:36, 31 July 2020

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