ReplaceString
ReplaceString (replaceThisStr, inStr, withThisStr [, caseSense [, maxReplace]])
The ReplaceString function returns inStr after replacing any instance of replaceThisStr with withThisStr.
The comparison of replaceThisStr to the contents of inStr is case-insensitive. Setting the optional caseSense parameter to nonzero makes the comparison case-sensitive.
Usually all instances of replaceThisStr are replaced. Setting the optional maxReplace parameter limits the replacements to that number.
Details
If replaceThisStr is not found, inStr is returned unchanged.
If maxReplace is less than 1, then no replacements are made. Setting maxReplace = Inf is the same as omitting it.
Examples
Print ReplaceString("hello", "say hello", "goodbye") // prints "say goodbye"
Print ReplaceString("\r\n", "line1\r\nline2", "") // prints "line1line2"
Print ReplaceString("A", "an Ack-Ack", "a", 1) // prints "an ack-ack"
Print ReplaceString("A", "an Ack-Ack", "a", 1, 1) // prints "an ack-Ack"
Print ReplaceString("", "input", "whatever") // prints "input" (no change)
See Also
ReplaceStringByKey, CmpStr, StringMatch, StrSearch, TrimString, ReplicateString