%% Extract Years from Series of Dates
% Define pat as a pattern with 4 numeric digits. Use pat to extract the years from the string array.

dates = ["November 4th 2015" "12/14/2019" "Jan. 1 2020" "28-Jan-2020 15:28:58"];
pat = digitsPattern(4);
year_array = extract(dates,pat)

% Copyright 2019 The MathWorks, Inc.