String::split
Split this string on occurrences of needle
.
"a,b".split(",") //-> ["a", "b"]
"ab".split(",") //-> ["ab"]
"a,,b,".split(",") //-> ["a", "", "b", ""]
"".split(",") //-> []
Source Codepublic method split(this: String, needle: String): List<String> {
if this == "" {
return []
}
let s = this
let parts: List<String> = []
while True {
match s.index_of(needle) {
Some(i) => {
parts = parts.append(s.substring(0, i))
s = s.substring(i + needle.len(), s.len())
}
None => {
parts = parts.append(s)
break
}
}
}
parts
}