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?