I have an old version of MATLAB which lacks the very useful strsplit
function documented here. Is there a way to replicate this functionality?
Asked
Active
Viewed 1,423 times
1

transversality condition
- 781
- 7
- 18
1 Answers
6
Yes! Use regexp
with the 'split'
option as follows. Note that it is necessary to escape characters which have special meaning when calling regexp
. regexescape = @(delim) regexprep(delim,'[\^\$()\<[{\\|>.*+\?]','\$0')
One line replacement function for strsplit
(courtesy of @AndrasDeak):
mystrsplit = @(str,delim) regexp(str,regexptranslate('escape',delim),'split')
Test cases:
>> strsplit('hi.mom','.')
ans =
'hi' 'mom'
>> mystrsplit('hi.mom','.')
ans =
'hi' 'mom'

transversality condition
- 781
- 7
- 18