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: Sun, 05 Oct 2003 10:08:08 -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 1065373849 10670 80.91.224.253 (5 Oct 2003 17:10:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 5 Oct 2003 17:10:49 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 05 19:10:47 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 1A6CP9-00042E-00 for ; Sun, 05 Oct 2003 19:10:47 +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 1A6COe-00071i-2m for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Oct 2003 13:10:16 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A6CNl-0006Tb-US for help-gnu-emacs@gnu.org; Sun, 05 Oct 2003 13:09:21 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A6CMm-0004Kj-Ah for help-gnu-emacs@gnu.org; Sun, 05 Oct 2003 13:08:51 -0400 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A6CMe-0004Fr-AP for help-gnu-emacs@gnu.org; Sun, 05 Oct 2003 13:08:12 -0400 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A6CMd-0004PW-00 for ; Sun, 05 Oct 2003 19:08:11 +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 1A6CMc-0004PO-00 for ; Sun, 05 Oct 2003 19:08:10 +0200 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A6CMc-0002iC-00 for ; Sun, 05 Oct 2003 19:08:10 +0200 Original-Lines: 45 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:12999 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12999 Oliver Scholz wrote: > Martin Stone Davis writes: > > >>Who likes `rx'? >>Who likes `sregex'? >>Who likes `rx' more than `sregex'? >>Who likes `sregex' more than `rx'? >>Why? > > >>>From the commentary section of rx.el: > > This is another implementation of sexp-form regular expressions. > It was unfortunately written without being aware of the Sregex > package coming with Emacs, but as things stand, Rx completely > covers all regexp features, which Sregex doesn't, doesn't suffer > from the bugs mentioned in the commentary section of Sregex, and > uses a nicer syntax (IMHO, of course :-). > > Personally I don't know about the nicer syntax, because I never tried > sregex. For the very reason that I discovered rx first. > > Oliver Thanks for pointing that out. I should have thought to read there. 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? I should also mention that sregex does not try to optimize `or' constructs. rx automatically runs regexp-opt on any (or ...) it sees. -Martin