Contents Previous Next Subchapters

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

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.

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,
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