gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/@tall/extractBetween.m
function s = extractBetween(str,startStr,endStr,varargin) %EXTRACTBETWEEN Create a string from part of a larger string. % S = EXTRACTBETWEEN(STR, START, END) % S = EXTRACTBETWEEN(..., 'Boundaries', B) % % EXTRACTBETWEEN on tall string arrays does not support expansion in the % first dimension. % % See also TALL/STRING. % Copyright 2016 The MathWorks, Inc. narginchk(3,5); % First input must be tall string. if ~istall(str) error(message('MATLAB:bigdata:array:ArgMustBeTall', 1, upper(mfilename))); end str = tall.validateType(str, mfilename, {'string'}, 1); % Treat all inputs slice-wise, wrapping char arrays if used. We allow % expansion or contraction in small dimensions, but not the tall dim. startStr = wrapCharInput(startStr); endStr = wrapCharInput(endStr); s = slicefun(@(a,b,c) iSubstring(a,b,c,varargin{:}), str, startStr, endStr); % extractBetween is allowed to change the non-tall dimensions, so reset % them. The output is the same type as the input. s.Adaptor = resetSmallSizes(str.Adaptor); end function out = iSubstring(in, varargin) % Call substring and check that it acted slice-wise. out = extractBetween(in, varargin{:}); if size(out,1) ~= size(in,1) % Tried to change the tall size error(message('MATLAB:bigdata:array:MultipleSubstrings')); end end