%% Lazy Matching Patterns
% The function wildcardPattern is lazy, which means it matches as few characters of any kind as needed, even zero.
% Extract a wildcardPattern from a string. There are empty strings between any two consecutive characters in a string, as well as before the first character and after the last. That is why extract matches and extracts five empty strings from this string.

txt = "lazy";
emptyStr = extract(txt,wildcardPattern)
strlength(emptyStr)

% If wildcardPattern is bounded by other patterns, it matches a minimum number of characters for the pattern expression to match.

txt = "aa aba abaa a a123a a!?.a";
pat = "a" + wildcardPattern + "a";
extract(txt,pat)

% Copyright 2020 The MathWorks, Inc.