Skip to content

StrRStrip

Description

Strip only trailing characters from s, returning a new Str. The original s is unmodified.

Parameters

Name Direction Description
s in Str to strip.
chars_to_strip in Optional Zstr listing characters to strip. NULL strips standard ASCII whitespace.

Success

Returns a new Str with trailing characters removed. s is not modified.

Failure

Returns a zero-length Str when the whole input strips away or on allocator OOM.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        // Test StrRStrip
        stripped = StrRStrip(&s1, NULL);
        result   = result && (ZstrCompare(StrBegin(&stripped), "  Hello") == 0);
        StrDeinit(&stripped);
        StrDeinit(&stripped);
    
        stripped = StrRStrip(&s1, "*");
        result   = result && (ZstrCompare(StrBegin(&stripped), "***Hello") == 0);
        StrDeinit(&stripped);
Last updated on