%% Specify Minimum Number of Patterns to Match
% Use asManyOfPattern to match as many individual letters as possible between two instances of "b", but require at least three letters.
% Create txt as a string. Create a pattern, pat, that matches as many of the letters "a" or "b" as possible between two instances of the character "b" but specify that there must be a minimum of three matched letters.

txt = "bb bab babab babaaabab";
pat = "b" + asManyOfPattern("a"|"b",3) + "b";

% Use replace to replace text matched by pat with the character "*".

replace(txt,pat,"*")

% Copyright 2020 The MathWorks, Inc.