From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Martin Stone Davis Newsgroups: gmane.emacs.help Subject: Re: rx vs sregex - a "match" to the death Date: Mon, 06 Oct 2003 01:41:13 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1065429873 7811 80.91.224.253 (6 Oct 2003 08:44:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Oct 2003 08:44:33 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 06 10:44:31 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A6Qyl-0005Sf-00 for ; Mon, 06 Oct 2003 10:44:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A6QxP-0004uS-KG for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Oct 2003 04:43:07 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A6QwD-0003Bx-KX for help-gnu-emacs@gnu.org; Mon, 06 Oct 2003 04:41:53 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A6Qve-0002XX-Lq for help-gnu-emacs@gnu.org; Mon, 06 Oct 2003 04:41:50 -0400 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A6Qvd-0002Uq-BG for help-gnu-emacs@gnu.org; Mon, 06 Oct 2003 04:41:17 -0400 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A6QvW-0007gy-00 for ; Mon, 06 Oct 2003 10:41:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A6QvV-0007gq-00 for ; Mon, 06 Oct 2003 10:41:09 +0200 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A6QvV-0001vo-00 for ; Mon, 06 Oct 2003 10:41:09 +0200 Original-Lines: 42 Original-X-Complaints-To: usenet@sea.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030925 X-Accept-Language: en-us, en In-Reply-To: X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:13011 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13011 Oliver Scholz wrote: > Martin Stone Davis 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? I think you're using backreference wrongly. Try the one I gave.It matches "Go, Spot, Go" OR "Run, Spot, Run". If I run (re-search-forward (sregexq (group (or "Go" "Run")) ", Spot, " (backref 1)) It finds either of those two phrases. -Martin