A copy of s with every non-overlapping old replaced by new, and how many were replaced.
replace :: (s: string, old: string, new: string) -> (string, ocurrences: int)
An empty old replaces nothing. The copy is allocated with the context allocator and the caller
frees it.
Parameters
- s: string
- old: string
- new: string
Returns
- string
- ocurrences: int
result, count := replace("aaaaa", "aa", "x");
defer free(result);
assert(result == "xxa" && count == 2);