Sample code for 30+ languages & platforms
Swift

StringBuilder ReplaceWord

Demonstrates the ReplaceWord method.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    let sb = CkoStringBuilder()!
    sb.append(value: "forest, lumber, lumberjack, jack, timberland")

    // The ReplaceWord method replaces word occurances.

    // For example:
    var numReplacements: Int = sb.replaceWord(value: "lumber", replacement: "timber").intValue
    numReplacements = sb.replaceWord(value: "jack", replacement: "joe").intValue

    // The string content is now:
    // forest, timber, lumberjack, joe, timberland
    print("\(sb.getAsString()!)")

}