Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

strrep - Find and replace substring

Syntax

modifiedStr = strrep(origStr, oldSubstr, newSubstr)

Description

modifiedStr = strrep(origStr, oldSubstr, newSubstr) replaces all occurrences of the string oldSubstr within string originalStr with the string newSubstr.

strrep(origStr, oldSubstr, newSubstr), when any of the inputs 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.

Examples

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'

See Also

strfind

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS