strrep

Purpose

String search and replace.

Synopsis

str = strrep('str1','old_str','new_str')

Description

str = strrep('str1','old_str','new_str') replaces all occurrences of a substring with another string, where

  • str1 is the string in which to search and replace.
  • old_str is the substring to replace within str1.
  • new_str is the string that replaces old_str.
    The function returns the modified string str.

    Examples

    s1 = 'This is a good example.';
    str = strrep(s1,'good','great')
              
    str =
    This is a great example.
    

    See Also

    findstr
    

    (c) Copyright 1994 by The MathWorks, Inc.