%% Match Individual Characters
% Use wildcardPattern to match individual characters of all types.
% Read the text from Shakespeare's Sonnets with the fileread function and convert it to string.

sonnets = string(fileread('sonnets.txt'));
strip(extractBetween(sonnets,"Shakespeare","But"))

% Create a pattern, pat, that matches one character of any type. Extract the pattern. Convert the string array characters to categorical so that it is a valid input for histogram. Display the occurrences of each character using histogram.

pat = wildcardPattern(1);
characters = extract(sonnets,pat);
characters = lower(characters);
characters = categorical(characters);
histogram(characters)

% Copyright 2020 The MathWorks, Inc.