chickadee » nutils » strim

strimprocedure
  • in - STR - the string to trim
  • in - OPTIONS:
    • Chars to trim are contained in strings/objects. The default set is " \t\n".
    • Keyword arguments include: L: <object>, R: <object> and D: <object>
    • If L: <object> is given and not false, object's characters are added to default set and applied only to left side of STR.
    • If R: <object> is given and not false, characters are added to default set and used to remove characters only from right side of STR.
    • If D: <object> is supplied, its characters replace the default set affecting both ends of STR.
    • If an optional argument is given, that is, a string/object without a keyword, its characters are added to the default set and used for character removal from both ends of STR.
    • Non-string objects (symbols, numbers, lists, etc.) must be convertible to strings.
  • returns: trimmed string
 (import nutils)
 (define str "\t\t---... A string. ---+++\n\n")
 (strim str "-.+") ;; => "A string" (note chars removed from both ends)
 (strim str "-+" L: ".") ;; => "A string." (L: -> rm . only from left end)
 (strim str "-+" L: '(\.)) ;; => "A string."
 (strim str "-+" L: '|.|)  ;; => "A string."