StrReplaceZstr
- Function
- August 22, 2025
Table of Contents
StrReplaceZstr
StrReplaceZstr
Description
Replace occurrences of a null-terminated string (Zstr) in string.
Parameters
Name | Direction | Description |
---|---|---|
s | in,out | Str to modify. |
match | in | Null-terminated match string. |
replacement | in | Null-terminated replacement string. |
count | in | Maximum number of replacements. -1 means replace all occurences. |
Success
Modifies s
in place.
Failure
No replacement if match
not found.
Usage example (Cross-references)
- In
Str.c:242
:
}
void StrReplaceZstr(Str* s, const char* match, const char* replacement, size count) {
ValidateStr(s);
str_replace(s, match, ZstrLen(match), replacement, ZstrLen(replacement), count);
- In
MisraDoc.c:181
:
StrMerge(&output_path, &file_path);
LOG_INFO("{}", output_path);
StrReplaceZstr(&output_path, "/", "-", -1);
LOG_INFO("{}", output_path);
- In
MisraDoc.c:210
:
StrPushFrontCstr(&output_path, project.build_dir.data, project.build_dir.length);
LOG_INFO("{}", output_path);
StrReplaceZstr(&output_path, ".c", ".md", 1);
StrReplaceZstr(&output_path, ".h", ".md", 1);
LOG_INFO("{}\n\n", output_path);
- In
MisraDoc.c:211
:
LOG_INFO("{}", output_path);
StrReplaceZstr(&output_path, ".c", ".md", 1);
StrReplaceZstr(&output_path, ".h", ".md", 1);
LOG_INFO("{}\n\n", output_path);
- In
Str.Ops.c:132
:
// Test StrReplaceZstr
Str s1 = StrInitFromZstr("Hello World");
StrReplaceZstr(&s1, "World", "Universe", 1);
bool result = (ZstrCompare(s1.data, "Hello Universe") == 0);
- In
Str.Ops.c:138
:
StrDeinit(&s1);
s1 = StrInitFromZstr("Hello Hello Hello");
StrReplaceZstr(&s1, "Hello", "Hi", 2);
result = result && (ZstrCompare(s1.data, "Hi Hi Hello") == 0);