On Thu, Apr 19, 2012 at 14:26, Eli Barzilay <e...@barzilay.org> wrote:

> Two hours ago, Laurent wrote:
>
> > Maybe also a `string-replace' could be useful, especially when one
> > does not want regexps and has special characters that need to be
> > quoted.
>
> Again, it's not clear how this shold look -- my guess:
>
>  (define (string-replace from str to)
>    (regexp-replace* (regexp-quote from) str to))
>

I meant this:

(define (string-replace from str to)
   (regexp-replace* (regexp-quote from) str (regexp-replace-quote to)))

(string-replace "(" "(a list)" "\\1")  ; -> "\\1a list)"

Newbie-friendly (I meant regexp-quoted without the user seeing it) and easy
to use.

Laurent
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev

Reply via email to