www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SelectTextWithInclusiveAndExclusiveBoundariesExample.m
%% Select Text with Inclusive and Exclusive Boundaries % Select text from string arrays with boundaries that are forced to be % inclusive or exclusive. |extractBetween| includes the boundaries with the % selected text when the boundaries are inclusive. |extractBetween| does % not include the boundaries with the selected text when the boundaries are % exclusive. % % Create a string array. Select the text between sixth and 13th positions, % but do not include the characters at those positions. str1 = string('small|medium|large') %% newStr = extractBetween(str1,6,13,'Boundaries','exclusive') %% % Select the text between two substrings, and also the substrings % themselves. str2 = string('The quick brown fox jumps over the lazy dog') %% newStr = extractBetween(str2,' brown','jumps','Boundaries','inclusive')