%% Replace Nonstandard Whitespaces
% Use whitespacePattern to place nonstandard whitespaces with the standard ' ' character.
% Create txt as a character vector.

txt = ['This' char(9) 'char' newline 'vector' char(160) 'has' char(32) 'nonstandard' char(8193) 'spaces']

% Create pat as a pattern object that matches individual whitespace characters using whitespacePattern. Replace the parts of text matched with a single space.

pat = whitespacePattern(1);
txt = replace(txt,pat," ")

% Copyright 2020 The MathWorks, Inc.