1
0
forked from Mirror/wren

Split and replace in wren.

This commit is contained in:
Andew Jones
2017-03-07 21:12:03 -05:00
parent 4fe3ad3f8b
commit 32aa43d1df
10 changed files with 158 additions and 0 deletions

View File

@ -129,6 +129,24 @@ negative to count backwards from the end of the string.
It is a runtime error if `search` is not a string or `start` is not an integer
index within the string's byte length.
### **split**(seperator)
Returns a list of one or more strings seperated by `seperator`.
:::wren
var string = "abc abc abc"
System.print(string.split(" ")) //> [abc, abc, abc]
It is a runtime error if `seperator` is not a string or is an empty string.
### **replace**(old, swap)
Returns a new string with all occurences of `old` replaced with `swap`.
:::wren
var string = "abc abc abc"
System.print(string.replace(" ", "")) //> abcabcabc
### **iterate**(iterator), **iteratorValue**(iterator)
Implements the [iterator protocol](../../control-flow.html#the-iterator-protocol)