%% Ignore Whitespaces in Expressions When Matching
% Create txt as a string.

txt = "Hello World";

% The expression '. *' only matches individual characters because of the whitespace between . and *. Create a pattern to match the regular expression '. *', and then extract the pattern.

expression = '. *';
pat = regexpPattern(expression);
extract(txt,pat)

% Create a new regular expression pattern, but this time specify FreeSpacing as true to ignore whitespaces in the regular expression. Extract the new pattern.

pat = regexpPattern(expression,"FreeSpacing",true);
extract(txt,pat)

% Copyright 2020 The MathWorks, Inc.