Skip to content

StrLStrip

Description

Strip only leading 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 leading 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 StrLStrip
        Str  s1       = StrInitFromZstr("  Hello  ", &alloc);
        Str  stripped = StrLStrip(&s1, NULL);
        bool result   = (ZstrCompare(StrBegin(&stripped), "Hello  ") == 0);
        StrDeinit(&stripped);
        s1 = StrInitFromZstr("***Hello***", &alloc);
    
        stripped = StrLStrip(&s1, "*");
        result   = result && (ZstrCompare(StrBegin(&stripped), "Hello***") == 0);
        StrDeinit(&stripped);
Last updated on