[racket] Fwd: regexp-match number

From: Louis-Philippe (default at spiralix.org)
Date: Wed Jun 22 11:26:58 EDT 2011

my use case is for substutition,  and so need to work with regex-replace, as
its third argument, I don't think the grouping operator works in that
case...  some named sub-expression could do it I believe, I can't find any
information about Racket supporting this, am I wrong?


2011/6/22 Matthew Flatt <mflatt at cs.utah.edu>

> You could wrap the "\1" with the grouping operator "(?:...)":
>
>  > (regexp-match #px"(.*)\\1001" "abcabc001")
>  bad pregexp string: backreference number is larger than the
>  highest-numbered cluster
>  > (regexp-match #px"(.*)(?:\\1)001" "abcabc001")
>  '("abcabc001" "abc")
>
> At Wed, 22 Jun 2011 09:52:09 -0400, Louis-Philippe wrote:
> > Hi all,
> >
> >    I have a small question about regexp-match:
> >
> >
> >    when I want to insert a sub-expression followed by a number what
> should I
> > write?
> >
> > like "\1001" to insert sub-expression 1 followed by 001
> >
> >    right now tries to insert sub-expression 1001...  is there a way to
> > escape this?
> >
> >
> > thanks!
> >
> >
> > L-P
> >
> >
> > p.s. I double posted on the IRC...  so the first good response I get I
> will
> > re-post, thanks!
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://lists.racket-lang.org/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110622/a07d808f/attachment.html>

Posted on the users mailing list.