| MATLAB Function Reference | ![]() |
str = strrep(str1, str2, str3)
str = strrep(str1, str2, str3) replaces all occurrences of the string str2 within string str1 with the string str3.
strrep(str1, str2, str3), when any of str1, str2, or str3 is a cell array of strings, returns a cell array the same size as str1, str2, and str3 obtained by performing a strrep using corresponding elements of the inputs. The inputs must all be the same size (or any can be a scalar cell). Any one of the strings can also be a character array with the right number of rows.
s1 = 'This is a good example.';
str = strrep(s1, 'good', 'great')
str =
This is a great example.
A =
'MATLAB' 'SIMULINK'
'Toolboxes' 'The MathWorks'
B =
'Handle Graphics' 'Real Time Workshop'
'Toolboxes' 'The MathWorks'
C =
'Signal Processing' 'Image Processing'
'MATLAB' 'SIMULINK'
strrep(A, B, C)
ans =
'MATLAB' 'SIMULINK'
'MATLAB' 'SIMULINK'![]() | strread | strtok | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |