[racket] regexp-replace* with input-port ==> Re: multi-replace function

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Dec 7 02:49:32 EST 2010

Two minutes ago, YC wrote:
> This brings up something I noticed earlier today looking at regexp
> docs: regexp-replace family does not work with input-port, when the
> other regexp-* functions do.
> Are there reasons for the difference?  Is it because input-port cannot be
> written to?

Well, that would be an obvious issue...  It might be possible to do
this if they're extended to get an output port too, something like:

  (regexp-replace* #rx"foo" inp "bar" outp)

doing the same thing as the loop that I wrote.

> But since the string & bytes variants all generate new output, that
> will seem to be the same for input-port source anyways.

(I didn't follow that.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.