--- On Wed, 5/9/12, Chad Albers <[email protected]> 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"


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to