[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rx vs sregex - a "match" to the death

From: Martin Stone Davis
Subject: Re: rx vs sregex - a "match" to the death
Date: Sun, 05 Oct 2003 10:08:08 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030925

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'?

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.


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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]