Sample code for 30+ languages & platforms
Ruby

StringBuilder RemoveAfterFinal

Demonstrates the StringBuilder.RemoveAfterFinal method.

The GetBefore method was added in Chilkat v9.5.0.77

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

sb = Chilkat::CkStringBuilder.new()
success = sb.Append("abc::def::ghi")

# Replace the 1st occurrence of a substring with another string.
bFound = sb.ReplaceFirst("::","-")

print "bFound = " + bFound.to_s() + "\n";
print "sb contains: " + sb.getAsString() + "\n";

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