bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#34641: rx: (or ...) order unpredictable


From: Noam Postavsky
Subject: bug#34641: rx: (or ...) order unpredictable
Date: Mon, 25 Feb 2019 09:43:07 -0500

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 via email to

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