Zig
Zig
StringBuilder RemoveAfterFinal
Demonstrates the StringBuilder.RemoveAfterFinal method.The GetBefore method was added in Chilkat v9.5.0.77
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const sb = try chilkat.StringBuilder.init();
defer sb.deinit();
try sb.append("abc::def::ghi");
// Replace the 1st occurrence of a substring with another string.
const b_found = if (sb.replaceFirst("::", "-")) true else |_| false;
std.debug.print("bFound = {}\n", .{b_found});
std.debug.print("sb contains: {s}\n", .{try sb.getAsString(alloc)});
// Output is:
// bFound = True
// sb contains: abc-def::ghi
}