split - This function is used to split a string
split([delimiter:string,maxloop:integer], string)
split is used to split a string on a delimiter. The default delimiter string is comma ','. The default value for maxloop is 1024.
The delimiter can be multiple characters.
This function can be use as a callback. In this case, each iteration will return one value. If the string is empty, the loop is not executed.
This function can be use a function in which case, the return value is an array of elements.
Note: In the followings examples, the _ between the { should be removed to make it work.
for i split("a,b,c") do i; endfor return abc for i split("") do i; endfor return nothing for i split("abc") do i; endfor return abc for i split(",,,abc,,,") do sn_nb; i; endfor return 0123abc456 for i split(delimiter: ":", ":a:") do sn_nb; i; endfor return 01a2 for i split(delimiter: "", "abc") do sn_nb; i; endfor return 0a1b2c for i split(delimiter: "", "") do sn_nb; i; endfor return nothing for i split(maxloop:2,delimiter: "", "pierre") do sn_nb; i; endfor return an error split(delimiter:" ","p i e r r e l a p l a n t e"); return ["p","i","e","r","r","e","l","a","p","l","a","n","t","e"] split(maxloop:4,delimiter:" ","p i e r r e l a p l a n t e"); }}.) return an error split(maxloop:4,delimiter:"","pierrelaplante"); }}.) return an error split("a,b,c"); split(delimiter:" , ", " , a , b , c , "); split(""); split("abcdef"); split(",,,abc,,,"); split(delimiter:"","abc"); split(delimiter:"",""); split(delimiter: " ", " a ") return ["a","b","c"]["","a","b","c",""][""]["abcdef"]["","","","abc","","",""]["a","b","c"][]["","a",""]
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>
1.0 2015-03-08 21:24:14 laplante@sednove.com
1.1 2015-04-21 21:27:00 laplante@sednove.com Make sure the loop is not executed on empty string
Edit© 2024 extenso Inc. All rights reserved.