From 0563590fe7b0fa4c184385b1d36191dfc747c3d5 Mon Sep 17 00:00:00 2001 From: altrisi Date: Mon, 11 Jan 2021 19:53:43 +0100 Subject: [PATCH] Document new split functions --- docs/scarpet/language/Containers.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/scarpet/language/Containers.md b/docs/scarpet/language/Containers.md index f017adaf..07d6993a 100644 --- a/docs/scarpet/language/Containers.md +++ b/docs/scarpet/language/Containers.md @@ -160,11 +160,19 @@ join('-', 'foo', 'bar') => foo-bar Splits a string under `expr` by `delim` which can be a regular expression. If no delimiter is specified, it splits by characters. +If `expr` is a list, it will split the list into multiple sublists by the element (s) which equal `delim`, or which equal the empty string +in case no delimiter is specified. + +Splitting a `null` value will return an empty list. +
 split('foo') => [f, o, o]
 split('','foo')  => [f, o, o]
 split('.','foo.bar')  => []
 split('\\.','foo.bar')  => [foo, bar]
+split(1,[2,5,1,2,3,1,5,6]) => [[2,5],[2,3],[5,6]]
+split(1,[1,2,3,1,4,5,1] => [[], [2,3], [4,5], []]
+split(null) => []
 
### `slice(expr, from, to?)`