%% Update Text in Words
% Replace words that begin with "s", end "e", and have at least one character between them. To match whole words, use "^" to match the start of a word and "$" to match the end of the word.

documents = tokenizedDocument([ ...
    "an example of a short sentence" 
    "a second short sentence"])
expression = "^s(\w+)e$";
replace = "thing";
newDocuments = regexprep(documents,expression,replace)

% If you do not use "^" and "$", then you can match substrings of the words. Replace all vowels with "_".

expression = "[aeiou]";
replace = "\_";
newDocuments = regexprep(documents,expression,replace)

%
% Copyright 2012 The MathWorks, Inc.