%% Count Characters in Text
% Use patterns to count the occurrences of individual characters in a piece of text.

txt = "She sells sea shells by the sea shore.";

% Create pat as a pattern object that matches individual letters using alphanumericsPattern. Extract the pattern.

pat = alphanumericsPattern(1);
letters = extract(txt,pat);

% Display a histogram of the number of occurrences of each letter.

letters = lower(letters);
letters = categorical(letters);
histogram(letters)

% Copyright 2020 The MathWorks, Inc.