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

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

Shy groups and * ...eh, what?


From: Michael Heerdegen
Subject: Shy groups and * ...eh, what?
Date: Sat, 22 Oct 2022 06:24:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hello,

I wanted to be sure I correctly understood that if you give multiple RX
arguments to the `rx' `*' operator, they are implicitly interpreted as a
sequence (AFAIU, that's the case.  An implicit `or' would also make
sense, that's why I wondered).

Anyway, here is what I tried:

(string-match-p
 (rx bos (* "a" "b") eos)
 "a")
==> 0

(string-match-p
 (rx bos (* "a" "b") eos)
 "b")
==> nil

Eh - what?  With evaluated `rx' forms this is

(string-match-p
 "\\`\\(?:ab\\)*\\'"
 "a")
==> 0

(string-match-p
 "\\`\\(?:ab\\)*\\'"
 "b")
==> nil

Makes no sense to me.  When I change the wrapping shy groups to normal
groups the result makes more sense to me:

(string-match-p
 "\\`\\(ab\\)*\\'"
 "a")
==> nil

(string-match-p
 "\\`\\(ab\\)*\\'"
 "b")
==> nil

Do I miss something or is it just a bug?


TIA,

Michael.



reply via email to

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