www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SelectTextBeforePositionInCharacterVectorExample.m
%% Select Text Before Position in Character Vector % Create a character vector. Then create new character vectors that are % substrings of |chr|. chr = 'peppers and onions' %% % Select the substring before the eighth position. newChr = extractBefore(chr,8) %% % Select text before a substring. newChr = extractBefore(chr,' and')