Sample code for 30+ languages & platforms
Swift

StringBuilder RemoveAfterFinal

Demonstrates the StringBuilder.RemoveAfterFinal method.

The GetBefore method was added in Chilkat v9.5.0.77

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let sb = CkoStringBuilder()!
    success = sb.append(value: "abc::def::ghi")

    // Replace the 1st occurrence of a substring with another string.
    var bFound: Bool = sb.replaceFirst(value: "::", replacement: "-")

    print("bFound = \(bFound)")
    print("sb contains: \(sb.getAsString()!)")

    // Output is:
    // bFound = True
    // sb contains: abc-def::gh

}