chickadee » nutils » trim-string

trim-string STRsyntax
trim-string STR BOTHsyntax
trim-string STR BOTH LEFT RIGHTsyntax
trim-string STR BOTH LEFT RIGHT DEFAULTsyntax
  • Similar to strim but more performant.
  • BOTH, LEFT, RIGHT, DEFAULT are strings and may be "".
  • Chars in BOTH are trimmed from left and right ends of STR.
  • Chars in LEFT/RIGHT are trimmed from the respective end of STR.
    • By default, chars in BOTH/LEFT/RIGHT are in addition to "\n", "\t" and " ".
  • Chars in DEFAULT replace the default trim chars.
 (import nutils)
 (define str "\t\t---... A string. ---+++\n\n")
 (trim-string str) ;; => "---... A string. ---+++"
 (trim-string str ".+-" ;; => "A string"
 (trim-string str "+-" "" ".") ;; => "... A string" (rm "." from right only)
 (trim-string str "" "-." "-+") ;; => "A string."
 (define str2 "---...Another string.--++")
 (trim-string str2 "" "" "" "-.+") ;; => "Another string"