[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rx vs sregex - a "match" to the death
From: |
Oliver Scholz |
Subject: |
Re: rx vs sregex - a "match" to the death |
Date: |
Mon, 06 Oct 2003 09:25:03 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt) |
Martin Stone Davis <m0davis@pacbell.net> writes:
[...]
> While I was comparing the two functions, I could not find if/how rx
> handles numbered backreferences. It's done in sregex like this:
>
> ;; (sregexq (group (or "Go" "Run"))
> ;; ", Spot, "
> ;; (backref 1)) => "\\(Go\\|Run\\), Spot, \\1"
>
> How do you do the same using rx?
[...]
Well, you could use (regexp "\\1"), but this is of course not
satisfying. I am not aware of any other way to use backrefs with `rx'.
However, I was not aware that you actually can use backrefs within a
regexp. I tried
(progn (looking-at "\\w+")
(forward-char 1)
(re-search-forward "\\0" nil t))
But that did not lead to the result that you would expect if backrefs
are/were supported within regexps.
Could you provide an example where this is meaningful?
Oliver
--
15 Vendémiaire an 212 de la Révolution
Liberté, Egalité, Fraternité!