Replace - replace a character or substring in a string

Return to Introduction  Previous page  Next page

$return = replace(string,oldString,newString)

Where:

$returnthe string with the specified characters replaced..
stringvariable containing text to be replaced..
oldStringthe string to replaced. Enclose oldString in double quotation marks ("") if it contains embedded spaces or commas.
newStringthe replacement string. Enclose newString in double quotation marks ("") if it contains embedded spaces or commas.        

 

string, oldString and newString may be variables.

The replace command replaces all occurrences of oldString in string with newString.

Example

$return = replace($variable,dog,cat)

 

Sample Script

' This script replaces fox with dog

 

$string = "The quick brown fox."

$old = "fox"

$new = "dog"

$return = replace($string,$old,$new)

MsgBox($return)

exit


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.