[racket] Rationale behind missing string-trim

From: William James (w_a_x_man at yahoo.com)
Date: Wed May 9 17:11:32 EDT 2012

--- On Wed, 5/9/12, Chad Albers <calbers at neomantic.com> wrote:

> I did write my own string-trim-both function using Racket's
> regexp as follows:
> (define (string-trim-both string)
>  (cadr (regexp-match #px"[\\s]*(\\S+)[\\s]*" string)))

Note: emails to this mailing-list should be in plain text.

(string-trim-both "  foo bar  ")
 ==> "foo"

(define (string-strip str)
  (regexp-replace* #px"^\\s+|\\s+$" str ""))

(string-strip "  \t  foo  bar  \t  ")
 ==> "foo  bar"

Posted on the users mailing list.