| 194 ## Replace Substrings |
194 ## Replace Substrings |
| 195 |
195 |
| 196 ```C |
196 ```C |
| 197 #include <cx/string.h> |
197 #include <cx/string.h> |
| 198 |
198 |
| 199 cxmutstr cx_strreplace(cxstring str, |
199 cxmutstr cx_strreplace(AnyStr str, |
| 200 cxstring search, cxstring replacement); |
200 AnyStr search, AnyStr replacement); |
| 201 |
201 |
| 202 cxmutstr cx_strreplace_a(const CxAllocator *allocator, cxstring str, |
202 cxmutstr cx_strreplace_a(const CxAllocator *allocator, AnyStr str, |
| 203 cxstring search, cxstring replacement); |
203 AnyStr search, AnyStr replacement); |
| 204 |
204 |
| 205 cxmutstr cx_strreplacen(cxstring str, |
205 cxmutstr cx_strreplacen(AnyStr str, |
| 206 cxstring search, cxstring replacement, size_t replmax); |
206 AnyStr search, AnyStr replacement, size_t replmax); |
| 207 |
207 |
| 208 cxmutstr cx_strreplacen_a(const CxAllocator *allocator, cxstring str, |
208 cxmutstr cx_strreplacen_a(const CxAllocator *allocator, AnyStr str, |
| 209 cxstring search, cxstring replacement, size_t replmax); |
209 AnyStr search, AnyStr replacement, size_t replmax); |
| 210 ``` |
210 ``` |
| 211 |
211 |
| 212 The function `cx_strreplace()` allocates a new string which will contain a copy of `str` |
212 The function `cx_strreplace()` allocates a new string which will contain a copy of `str` |
| 213 where every occurrence of `search` is replaced with `replacement`. |
213 where every occurrence of `search` is replaced with `replacement`. |
| 214 The new string is guaranteed to be zero-terminated even if `str` is not. |
214 The new string is guaranteed to be zero-terminated even if `str` is not. |