; strip : string -> string
; remove white space from the beginning and end of a string
(definestrip
(let ([r-strip (regexp"^[ \t\r]*(.*?)[ \t\r]*$")])
(lambda (s)
(cadr (regexp-matchr-strips)))))
The solution uses a regular expression to pick out the middle of the string.
The regular expression is compiled only once, namely when strip is defined.