core :: Text :: split_once_on
self
on the first occurence of pattern
assert "hello".split_once_on('l') == ["he", "lo"]
assert "a, b, c, d, e".split_once_on(", ") == ["a", "b, c, d, e"]
# Split `self` on the first occurence of `pattern`
#
# assert "hello".split_once_on('l') == ["he", "lo"]
# assert "a, b, c, d, e".split_once_on(", ") == ["a", "b, c, d, e"]
fun split_once_on(pattern: Pattern): Array[SELFTYPE]
do
var m = pattern.search_in(self, 0)
var res = new Array[SELFTYPE]
if m == null then
res.add self
else
res.add substring(0, m.from)
res.add substring_from(m.after)
end
return res
end
lib/core/text/string_search.nit:456,2--471,4