all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: 34641@debbugs.gnu.org
Subject: bug#34641: rx: (or ...) order unpredictable
Date: Mon, 25 Feb 2019 09:43:07 -0500	[thread overview]
Message-ID: <CAM-tV-8j6rFtM+k-toB6-F8yS-3RZsd8Y50iEQWZ7vydOV9wLA@mail.gmail.com> (raw)
In-Reply-To: <07B35E27-3082-4DDD-A1C9-0D8286D40452@acm.org>

On Mon, 25 Feb 2019 at 04:56, Mattias Engdegård <mattiase@acm.org> wrote:

> Good question! When the match is anchored at the end, they are indeed equivalent. They also are equivalent for Posix regexps, which prefer the longest match. But in Emacs, the first (leftmost) matching alternative is used.
>
> Suppose we are matching against the string "abc". Then
> ab\|a matches "ab"
> a\|ab matches "a"

Oh, huh. So it does. I guess I've never used regexp in a situation
where this subtle corner case would come up.

> >> (Speaking of regexp-opt, it has another bug that does not affect rx: it returns the empty string if given an empty list of strings. The correct return value is a regexp that never matches anything.
> >
> > This sounds familiar, though I can't locate a report for it.
>
> If you do remember, please tell us about it.
> The `or' operator in SRE can be used with an empty argument list, and will then not match anything. It is a useful limit case for machine-generated regexps.

Right, found it this time, it's Bug#20307.





  reply	other threads:[~2019-02-25 14:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-24 18:40 bug#34641: rx: (or ...) order unpredictable Mattias Engdegård
2019-02-24 19:06 ` Eli Zaretskii
2019-02-24 21:18   ` Mattias Engdegård
2019-02-24 22:44     ` Basil L. Contovounesios
2019-02-25 14:26       ` Mattias Engdegård
2019-03-02 12:33     ` Eli Zaretskii
2019-03-02 14:05       ` Mattias Engdegård
2019-03-02 14:08         ` Mattias Engdegård
2019-03-02 14:23           ` Eli Zaretskii
2019-03-02 14:37             ` Mattias Engdegård
2019-03-02 23:48       ` Phil Sainty
2019-03-03  8:54         ` Mattias Engdegård
2019-03-07  9:00           ` Phil Sainty
2019-02-25  2:37 ` Noam Postavsky
2019-02-25  9:56   ` Mattias Engdegård
2019-02-25 14:43     ` Noam Postavsky [this message]
2019-02-25 14:48       ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM-tV-8j6rFtM+k-toB6-F8yS-3RZsd8Y50iEQWZ7vydOV9wLA@mail.gmail.com \
    --to=npostavs@gmail.com \
    --cc=34641@debbugs.gnu.org \
    --cc=mattiase@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.