> #lang racket > > (define (fix str) > (define tmp str) > (set! tmp (regexp-replace* " / " tmp "_")) > (set! tmp (regexp-replace* " " tmp "_")) > (set! tmp (regexp-replace* "%" tmp "")) > (set! tmp (regexp-replace* "-" tmp "_")) > (string-upcase tmp))
The several uses of regexp-replace* can be simplified a little by passing regexp-replace* a function rather than a string. This allows you to dynamically provide the rewrite. For example: ;;;;;; > (regexp-replace* "[/ %-]" "this/is%a-test right?" (lambda (s) (if (string=? s "%") "" "_"))) "this_isa_test_right?" ;;;;;; ____________________ Racket Users list: http://lists.racket-lang.org/users