%% Parse Delimited Text into String Array
% Create a string that contains sample HTML code. Break it down into segments delimited by the < and > characters. Store the segments in a string array.
% Starting in R2017a, you can create strings using double quotes. To concatenate several strings into one string, use the plus operator, +.

str = "<ul class=continued><li class=continued>" + ...
      "<pre><a name=""13474""></a>token = strtok" + ...
      "(str,delimiter)<a name=""13475""></a>" + ...
      "token = strtok(str)"

%
% Create an empty string array to contain the code segments.

segments = strings(0)

%
% Break str into segments. Write a while loop that repeatedly calls strtok on the remaining HTML text. The while loop exits when there is no more text to parse.

remain = str;
while (remain ~= "")
   [token,remain] = strtok(remain, '<>');
   segments = [segments ; token];
end

%
% Display the code segments.

segments

% Copyright 2012 The MathWorks, Inc.