Contents Previous Next Subchapters

Substituting Strings in Character Matrices
Syntax strreplace(xoldStringnewString)
strreplace(
xoldStringnewStringmatchCase)
See Also lower , ntoa , atod , atoi , char , file2str , align , find2

Description
Replaces all occurrences of the character row vector oldString with the character row vector newString in the character matrix x. If present, the argument matchCase must be a logical scalar which specifies if case matching should be used when replacing strings.

Examples
If you enter,
     strreplace("Hello World", "Hello", "Hi")
O-Matrix will respond
     Hi World
The strreplace function can also replace strings in matrices with more than one row and patterns that do not have the same length. If you enter
     M = {"aA1a","a1"}
     strreplace(M, "a", "bb")
O-Matrix will return,
    bbA1bb
    bb1 
By default, the strreplace function is case sensitive, and patterns must match exactly to be replaced. If you continue the example above by entering,
     strreplace(M, "a", "bb", false)
O-Matrix will respond
    bbbb1bb
    bb1