StrReplaceCstr

Table of Contents

StrReplaceCstr

Description

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

Parameters

NameDirectionDescription
sin,outStr to modify.
matchinMatch string pointer.
match_leninLength of match string.
replacementinReplacement string pointer.
replacement_leninLength of replacement string.
countinMaximum number of replacements. -1 means replace all occurences.

Success

Modifies s in place.

Failure

No replacement if match not found.

Usage example (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);

Share :