Skip to content
StrReplaceCstr

StrReplaceCstr

StrReplaceCstr

Description

Replace occurrences of a fixed-length string (Cstr) in string.

Parameters

Name Direction Description
s in,out Str to modify.
match in Match string pointer.
match_len in Length of match string.
replacement in Replacement string pointer.
replacement_len in Length of 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)

Usage examples (Cross-references)
    }
    
    void StrReplaceCstr(
        Str        *s,
        const char *match,
        StrDeinit(&s1);
        s1 = StrInitFromZstr("Hello World");
        StrReplaceCstr(&s1, "World", 5, "Universe", 8, 1);
        result = result && (ZstrCompare(s1.data, "Hello Universe") == 0);
Last updated on