* [ruby-core:115931] [Ruby master Bug#20097] Regexp#match? with empty capture group repeat is inconsistent
@ 2023-12-27 10:56 tompng (tomoya ishida) via ruby-core
2023-12-28 14:55 ` [ruby-core:115962] " dentarg (Patrik Ragnarsson) via ruby-core
2023-12-28 19:43 ` [ruby-core:115967] " tompng (tomoya ishida) via ruby-core
0 siblings, 2 replies; 3+ messages in thread
From: tompng (tomoya ishida) via ruby-core @ 2023-12-27 10:56 UTC (permalink / raw
To: ruby-core; +Cc: tompng (tomoya ishida)
Issue #20097 has been reported by tompng (tomoya ishida).
----------------------------------------
Bug #20097: Regexp#match? with empty capture group repeat is inconsistent
https://bugs.ruby-lang.org/issues/20097
* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
It sometimes matches and sometimes does not, depend on repeat quantifier number.
~~~ruby
# empty capture group repeat
p /(a(){1,4}){2}/.match?('aa') #=> true
p /(a(){1,5}){2}/.match?('aa') #=> false
# repeat of capture group that match to empty string
p /(a(|){1,2}){2}/.match?('aa') #=> true
p /(a(|){1,3}){2}/.match?('aa') #=> false
p /(a(x?y?|z){1,2}){2}/.match?('aa') #=> false
~~~
non-capturing group seems ok.
~~~ruby
p /(a(?:){1,4}){2}/.match?('aa') #=> true
p /(a(?:){1,5}){2}/.match?('aa') #=> true
p /(a(?:|){1,2}){2}/.match?('aa') #=> true
p /(a(?:|){1,3}){2}/.match?('aa') #=> true
p /(a(?:x?y?|z){1,2}){2}/.match?('aa') #=> true
~~~
Same behavior in ruby 3.0, 3.1, 3.2
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:115962] [Ruby master Bug#20097] Regexp#match? with empty capture group repeat is inconsistent
2023-12-27 10:56 [ruby-core:115931] [Ruby master Bug#20097] Regexp#match? with empty capture group repeat is inconsistent tompng (tomoya ishida) via ruby-core
@ 2023-12-28 14:55 ` dentarg (Patrik Ragnarsson) via ruby-core
2023-12-28 19:43 ` [ruby-core:115967] " tompng (tomoya ishida) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: dentarg (Patrik Ragnarsson) via ruby-core @ 2023-12-28 14:55 UTC (permalink / raw
To: ruby-core; +Cc: dentarg (Patrik Ragnarsson)
Issue #20097 has been updated by dentarg (Patrik Ragnarsson).
Same as https://bugs.ruby-lang.org/issues/20083?
----------------------------------------
Bug #20097: Regexp#match? with empty capture group repeat is inconsistent
https://bugs.ruby-lang.org/issues/20097#change-105920
* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
It sometimes matches and sometimes does not, depend on repeat quantifier number.
~~~ruby
# empty capture group repeat
p /(a(){1,4}){2}/.match?('aa') #=> true
p /(a(){1,5}){2}/.match?('aa') #=> false
# repeat of capture group that match to empty string
p /(a(|){1,2}){2}/.match?('aa') #=> true
p /(a(|){1,3}){2}/.match?('aa') #=> false
p /(a(x?y?|z){1,2}){2}/.match?('aa') #=> false
~~~
non-capturing group seems ok.
~~~ruby
p /(a(?:){1,4}){2}/.match?('aa') #=> true
p /(a(?:){1,5}){2}/.match?('aa') #=> true
p /(a(?:|){1,2}){2}/.match?('aa') #=> true
p /(a(?:|){1,3}){2}/.match?('aa') #=> true
p /(a(?:x?y?|z){1,2}){2}/.match?('aa') #=> true
~~~
Same behavior in ruby 3.0, 3.1, 3.2
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:115967] [Ruby master Bug#20097] Regexp#match? with empty capture group repeat is inconsistent
2023-12-27 10:56 [ruby-core:115931] [Ruby master Bug#20097] Regexp#match? with empty capture group repeat is inconsistent tompng (tomoya ishida) via ruby-core
2023-12-28 14:55 ` [ruby-core:115962] " dentarg (Patrik Ragnarsson) via ruby-core
@ 2023-12-28 19:43 ` tompng (tomoya ishida) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: tompng (tomoya ishida) via ruby-core @ 2023-12-28 19:43 UTC (permalink / raw
To: ruby-core; +Cc: tompng (tomoya ishida)
Issue #20097 has been updated by tompng (tomoya ishida).
Not same. https://bugs.ruby-lang.org/issues/20083 is related to regexp optimization from ruby 3.2.
This issue is not because it's same result in older ruby version 3.0 and 3.1
----------------------------------------
Bug #20097: Regexp#match? with empty capture group repeat is inconsistent
https://bugs.ruby-lang.org/issues/20097#change-105926
* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
It sometimes matches and sometimes does not, depend on repeat quantifier number.
~~~ruby
# empty capture group repeat
p /(a(){1,4}){2}/.match?('aa') #=> true
p /(a(){1,5}){2}/.match?('aa') #=> false
# repeat of capture group that match to empty string
p /(a(|){1,2}){2}/.match?('aa') #=> true
p /(a(|){1,3}){2}/.match?('aa') #=> false
p /(a(x?y?|z){1,2}){2}/.match?('aa') #=> false
~~~
non-capturing group seems ok.
~~~ruby
p /(a(?:){1,4}){2}/.match?('aa') #=> true
p /(a(?:){1,5}){2}/.match?('aa') #=> true
p /(a(?:|){1,2}){2}/.match?('aa') #=> true
p /(a(?:|){1,3}){2}/.match?('aa') #=> true
p /(a(?:x?y?|z){1,2}){2}/.match?('aa') #=> true
~~~
Same behavior in ruby 3.0, 3.1, 3.2
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-28 19:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-27 10:56 [ruby-core:115931] [Ruby master Bug#20097] Regexp#match? with empty capture group repeat is inconsistent tompng (tomoya ishida) via ruby-core
2023-12-28 14:55 ` [ruby-core:115962] " dentarg (Patrik Ragnarsson) via ruby-core
2023-12-28 19:43 ` [ruby-core:115967] " tompng (tomoya ishida) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).