StrLStrip

Table of Contents

StrLStrip

Description

Strip only leading whitespace (or optional custom characters) from the given Str object. Returns a new Str object. Original is unmodified.

Parameters

NameDirectionDescription
strinStr object to strip
chars_to_stripinOptional zero-terminated char pointer specifying which characters to strip. If NULL, standard ASCII whitespace is stripped.

Success

A new Str object with leading characters removed

Failure

A zero-length Str object

Usage example (Cross-references)

    // Test StrLStrip
    Str  s1       = StrInitFromZstr("  Hello  ");
    Str  stripped = StrLStrip(&s1, NULL);
    bool result   = (ZstrCompare(stripped.data, "Hello  ") == 0);
    StrDeinit(&stripped);
    s1 = StrInitFromZstr("***Hello***");
    
    stripped = StrLStrip(&s1, "*");
    result   = result && (ZstrCompare(stripped.data, "Hello***") == 0);
    StrDeinit(&stripped);

Share :