www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/IncludeDynamicExpressioninReplacementTextExample.m

    %% Include Dynamic Expression in Replacement Text  
% Replace lowercase letters at the beginning of sentences with their uppercase
% equivalents using the |upper| function.   

%%  
str = 'here are two sentences. neither is capitalized.';
expression = '(^|\.)\s*.';
replace = '${upper($0)}';

newStr = regexprep(str,expression,replace) 

%%
% The regular expression matches single characters (|.|) that follow the
% beginning of the character vector |(^)| or a period |(\.)| and any whitespace |(\s*)|.
% The |replace| expression calls the |upper| function for the currently
% matching character (|$0|).