%% Match Boundaries of Digit Characters
% Use digitBoundary to divide a string along boundaries between digits and nondigit characters.
% Create a pattern that matches any digit boundaries.

txt = "123 abc .?! def 456";
pat = digitBoundary;

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

replace(txt,pat,"|")

% Copyright 2020 The MathWorks, Inc.