docs/Writerside/topics/string.h.md

changeset 1221
304f4f7b37d1
parent 1220
e9dfb1e92481
equal deleted inserted replaced
1220:e9dfb1e92481 1221:304f4f7b37d1
176 ## Replace Substrings 176 ## Replace Substrings
177 177
178 ```C 178 ```C
179 #include <cx/string.h> 179 #include <cx/string.h>
180 180
181 cxmutstr cx_strreplace(cxstring str, cxstring pattern, cxstring repl); 181 cxmutstr cx_strreplace(cxstring str,
182 cxstring search, cxstring replacement);
182 183
183 cxmutstr cx_strreplace_a(const CxAllocator *allocator, cxstring str, 184 cxmutstr cx_strreplace_a(const CxAllocator *allocator, cxstring str,
184 cxstring pattern, cxstring repl); 185 cxstring search, cxstring replacement);
185 186
186 cxmutstr cx_strreplacen(cxstring str, cxstring pattern, cxstring repl, 187 cxmutstr cx_strreplacen(cxstring str,
187 size_t replmax); 188 cxstring search, cxstring replacement, size_t replmax);
188 189
189 cxmutstr cx_strreplacen_a(const CxAllocator *allocator, cxstring str, 190 cxmutstr cx_strreplacen_a(const CxAllocator *allocator, cxstring str,
190 cxstring pattern, cxstring repl, size_t replmax); 191 cxstring search, cxstring replacement, size_t replmax);
191 ``` 192 ```
192 193
193 > Documentation work in progress. 194 The function `cx_strreplace()` allocates a new string which will contain a copy of `str`
194 >{style="warning"} 195 where every occurrence of `search` is replaced with `replacement`.
196 The new string is guaranteed to be zero-terminated even if `str` is not.
197
198 The function `cx_strreplace_a()` uses the specified `allocator` to allocate the new string.
199
200 The functions `cx_strreplacen()` and `cx_strreplacen_a()` are equivalent, except that they stop
201 after `replmax` number of replacements.
195 202
196 ## Basic Splitting 203 ## Basic Splitting
197 204
198 ```C 205 ```C
199 #include <cx/string.h> 206 #include <cx/string.h>

mercurial