%% Ignore Case with Regular Expressions
% Find words that start with c, end with t, and contain one or more vowels in between, regardless of case.

txt = "bat cat can car coat court CUT ct CAT-scan";
expression = 'c[aeiou]+t';

% The regular expression 'c[aeiou]+t' specifies this pattern:
% c must be the first character.
% c must be followed by one of the characters inside the brackets, [aeiou].
% The bracketed pattern must occur one or more times, as indicated by the + operator.
% t must be the last character, with no characters between the bracketed pattern and the t.
% Extract the pattern. Note that the words CUT and CAT do not match because they are uppercase.

pat = regexpPattern(expression);
extract(txt,pat)

% Create a new regular expression pattern, but this time specify IgnoreCase as true to ignore case with the regular expression. Extract the new pattern.

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

% Copyright 2020 The MathWorks, Inc.