%% Match Boundaries of Whitespaces
% Use whitespaceBoundary to divide a string along whitespace boundaries. This pattern matches boundaries between a whitespace character and a non-whitespace character.
% Create a pattern that matches any whitespace boundaries.

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

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

replace(txt,pat,"|")

%
% Copyright 2020 The MathWorks, Inc.