StrStrip
StrStrip
Description
Strip leading and trailing whitespace (or optional custom characters) from the given Str object. Returns a new Str object. Original is unmodified. The returned Str must be deinited after use.
Parameters
| Name | Direction | Description |
|---|---|---|
str |
in | Str object to strip |
chars_to_strip |
in | Optional zero-terminated char pointer specifying which characters to strip. If NULL, standard ASCII whitespace is stripped. |
Success
A new Str object with surrounding characters removed
Failure
A zero-length Str object
Usage example (Cross-references)
Usage examples (Cross-references)
- In
KvConfig.c:288:
if (value->length > 0) {
Str stripped = StrStrip(value, NULL);
StrDeinit(value);
*value = stripped;- In
Str.Ops.c:209:
// Test string strip functions
bool test_str_strip(void) {
WriteFmt("Testing StrStrip variants\n");
// Test StrLStrip
- In
Str.Ops.c:223:
// Test StrStrip
stripped = StrStrip(&s1, NULL);
result = result && (ZstrCompare(stripped.data, "Hello") == 0);
StrDeinit(&stripped);- In
Str.Ops.c:239:
StrDeinit(&stripped);
stripped = StrStrip(&s1, "*");
result = result && (ZstrCompare(stripped.data, "Hello") == 0);
StrDeinit(&stripped);
Last updated on