GNU bug report logs -
#34641
rx: (or ...) order unpredictable
Previous Next
Full log
View this message in rfc822 format
On Mon, 25 Feb 2019 at 04:56, Mattias Engdegård <mattiase <at> 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.
This bug report was last modified 6 years and 72 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.