Hi,
if anybody has used the 'sepstr2arr' function in the 'extra' addon
(which used to be a regular function package until recently, and
from the point of view of the user the difference is not very
relevant):
This function is going to be removed from 'extra' very soon.
The reason is that in 2018a the built-in strsplit function was
extended to cover that functionality, as noted in the changelog:
"strsplit() function: add optional third argument to choose the
separator on which to split strings"
So for standard usage, you just have to directly replace
'sepstr2arr' with 'strsplit' in your code.
However, there is a subtle change that might affect some corner
cases, and for completeness here's an explanation of how to deal
with that. The difference is that sepstr2arr only used the first
character of the separation string argument, so if you passed a
double comma (",,") only a single comma was actually taken. In
contrast, the built-in strsplit honors your more complex separator
string. See the following examples to help achieve what you want in
these (not very common) cases:
<hansl>
include extra.gfn
string s = "hey,,ho,let's,go"
string sep = ",,"
# old sepstr2arr:
# merges ",," to a single separator
eval sepstr2arr(s, sep) # gives 4 elements
# case where direct substitution does not work:
eval strsplit(s, sep) # splits on ",," - gives 2 elements
# Get (almost) the behavior from sepstr2arr with strsplit:
eval strsplit(s, sep[1]) # splits on "," - gives 5 elements (one
empty)
# Get (exactly) the behavior from sepstr2arr with strsplit:
# uses the fact that multiple whitespace characters are merged
eval strsplit(strsub(s, sep[1], " ")) # gives 4 elements
</hansl>
But again, I guess in 95% of the cases you just replace sepstr2arr
with strsplit and you're done.
Thanks,
Sven