Sample code for 30+ languages & platforms
Xbase++

StringBuilder RemoveAfterFinal

Demonstrates the StringBuilder.RemoveAfterFinal method.

The GetBefore method was added in Chilkat v9.5.0.77

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oSb
LOCAL cMarker
LOCAL nBFound

nSuccess := 0

oSb := CreateObject("Chilkat.StringBuilder")
nSuccess := oSb:Append("abc::def::ghi")

//  The RemoveAfterFinal method removes the chars after the final occurrence of the marker.
//  It also removes the marker string.
//  If the marker is not found, then nothing is removed and the method returns 0.
cMarker := "::"
nBFound := oSb:RemoveAfterFinal(cMarker)

? "bFound = " + Str(nBFound)
? "sb contains: " + oSb:GetAsString()

//  Output is:
//  bFound = 1
//  sb contains: abc::def

oSb:destroy()