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

    %% Replace Zero-Length Matches  
% Insert text at the beginning of a character vector using the |'^'| operator, which
% returns a zero-length match, and the |'emptymatch'| keyword.   

%%  
str = 'abc';
expression = '^';
replace = '__';

newStr = regexprep(str,expression,replace,'emptymatch')