%% 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')

% Copyright 2012 The MathWorks, Inc.