%% Escape Special Characters in Replacement Text
% Create a string. Starting in R2017a, you can create strings using double quotes.

str = "Put your money in."

%
% Specify the text, '$0.02', as the text to replace the word 'money'. To escape the '$' and '.' characters, use regexptranslate.

r = regexptranslate('escape','$0.02')

%
% Replace 'money' using the regexprep function.

newStr = regexprep(str,'money',r)

% Copyright 2012 The MathWorks, Inc.