--- a/docs/Writerside/topics/string.h.md Fri Feb 21 21:06:07 2025 +0100 +++ b/docs/Writerside/topics/string.h.md Sat Feb 22 18:55:25 2025 +0100 @@ -178,20 +178,27 @@ ```C #include <cx/string.h> -cxmutstr cx_strreplace(cxstring str, cxstring pattern, cxstring repl); +cxmutstr cx_strreplace(cxstring str, + cxstring search, cxstring replacement); cxmutstr cx_strreplace_a(const CxAllocator *allocator, cxstring str, - cxstring pattern, cxstring repl); + cxstring search, cxstring replacement); -cxmutstr cx_strreplacen(cxstring str, cxstring pattern, cxstring repl, - size_t replmax); +cxmutstr cx_strreplacen(cxstring str, + cxstring search, cxstring replacement, size_t replmax); cxmutstr cx_strreplacen_a(const CxAllocator *allocator, cxstring str, - cxstring pattern, cxstring repl, size_t replmax); + cxstring search, cxstring replacement, size_t replmax); ``` -> Documentation work in progress. ->{style="warning"} +The function `cx_strreplace()` allocates a new string which will contain a copy of `str` +where every occurrence of `search` is replaced with `replacement`. +The new string is guaranteed to be zero-terminated even if `str` is not. + +The function `cx_strreplace_a()` uses the specified `allocator` to allocate the new string. + +The functions `cx_strreplacen()` and `cx_strreplacen_a()` are equivalent, except that they stop +after `replmax` number of replacements. ## Basic Splitting