Text processing - replacing text


Short of making a wrapper function, is there syntax for the replace command that returns the result of the replace operation, rather than modifying a source variable?


I wanted to do the same and came up with this:

put "abc" split by "b" joined by "B"        -- prints "aBc"

If you’re expecting to write a function that should return the replaced text but not alter the passed one, this might help.

function ReplaceText(sourceText, txtToFind, txtToReplaceWith)
   put sourceText into srcTxt
   replace every occurrence of  txtToFind in srcTxt with txtToReplaceWith
   return srcText
end function