Skip to content

Latest commit

 

History

History
15 lines (10 loc) · 777 Bytes

string-trim.md

File metadata and controls

15 lines (10 loc) · 777 Bytes

string-trim

(string-trim character-bag string)

Returns a new string with all leading and trailing characters that appear in character-bag removed; interior characters are untouched. character-bag is any sequence of characters -- a string, a list, or a vector -- whose members form the set to strip. Trimming stops at the first character on each end that is not in the bag.

string is a string designator, so a symbol or a character is accepted and its name is trimmed: (string-trim "*" '*foo*) returns "FOO". character-bag is NOT a designator -- it is a sequence -- so a lone character there is an error, not a one-character bag.

(string-trim " " "  hi  ") ; => "hi"
(string-trim (list #\Space #\Tab) "  hi  ") ; => "hi"