Sample code for 30+ languages & platforms
Xbase++

StringBuilder ReplaceWord

Demonstrates the ReplaceWord method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL oSb
LOCAL nNumReplacements

oSb := CreateObject("Chilkat.StringBuilder")
oSb:Append("forest, lumber, lumberjack, jack, timberland")

//  The ReplaceWord method replaces word occurances.

//  For example:
nNumReplacements := oSb:ReplaceWord("lumber", "timber")
nNumReplacements := oSb:ReplaceWord("jack", "joe")

//  The string content is now:
//  forest, timber, lumberjack, joe, timberland
? oSb:GetAsString()

oSb:destroy()