%% Match End Boundaries of Text
% Use the "end" option for textBoundary to match the specified endpoint of a piece of text.
% Create a string array with multiple pieces of text. Create a pattern that matches the last word of each piece of text.

txts = ["This is the first piece of text" 
    "Here is the second" 
    "Now there are three"];
pat = lettersPattern + textBoundary("end");

% Extract the pattern.

lastWords = extract(txts,pat)

% Copyright 2020 The MathWorks, Inc.