Avoid allocations by performing stripping in-place

Introduce a helper function (string_strip_delimited).
Consistent indentation.
Avoid allocations in string_replace_at when possible.