%% Match Digits Except Those That Follow Pattern
% Use the ~ operator to negate lookBehindBoundary.
% Create a pattern that matches digits except for those that directly follow "b" or "2".

txt = "abc 123";
pat = ~lookBehindBoundary("b"|"2");

% Use replace to insert "|" characters at the negated boundaries.

replace(txt,pat,"|")

% Copyright 2020 The MathWorks, Inc.