split.m

来自「Video IO toolbox for matlab. 用directsho」· M 代码 · 共 19 行

M
19
字号
function l = split(d,s)
%L=SPLIT(S,D) splits a string S delimited by characters in D.  Meant to
%             work roughly like the PERL split function (but without any
%             regular expression support).  Internally uses STRTOK to do 
%             the splitting.  Returns a cell array of strings.
%
%Example:
%    >> split('_/', 'this_is___a_/_string/_//')
%    ans = 
%        'this'    'is'    'a'    'string'   []
%
%Written by Gerald Dalley (dalleyg@mit.edu), 2004

l = {};
while ~isempty(s)
    [t,s] = strtok(s,d); %#ok<STTOK> -- textscan isn't powerful enough
    l = {l{:}, t};
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?