%% Replace Text with Regular Expression
% Create a character vector that contains words separated by whitespace characters, such as spaces and newline characters.

chr = 'Whose woods these are I think I know.';
chr = [chr newline 'His house is in the village though']

%
% Specify '\s' as a regular expression that matches whitespace characters. Then replace those characters in chr.

expression = '\s';
newChr = regexptranslate('flexible',chr,expression)

% Copyright 2012 The MathWorks, Inc.