%% Split Text with Multiple, Overlapping Delimiters
% Split text on the character vectors ', ' and ', and '.

str = 'bacon, lettuce, and tomato';
[C,matches] = strsplit(str,{', ',', and '})

% Because the command lists ', ' first and ', and ' contains ', ', the strsplit function splits str on the first delimiter and never proceeds to the second delimiter.
%
% If you reverse the order of delimiters, ', and ' takes priority.

str = 'bacon, lettuce, and tomato';
[C,matches] = strsplit(str,{', and ',', '})

% Copyright 2012 The MathWorks, Inc.