
Issue #20098 has been updated by nagachika (Tomoyuki Chikanaga). The changeset bb59696614083660241ef272f222628cbfa95844 cannot be merged into ruby_3_2 branch cleanly and hard to me to write a patch. @tompng Could you kindly create the patch for ruby_3_2 branch? ---------------------------------------- Bug #20098: Wrong regexp match in ruby 3.2 and 3.3 https://bugs.ruby-lang.org/issues/20098#change-107543 * Author: tompng (tomoya ishida) * Status: Closed * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22] * Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED, 3.3: DONE ---------------------------------------- These regexp all matches in ruby 3.1.4, but not in ruby 3.3.0. ~~~ruby p /a((.|.)|bc){,4}z/.match? 'abcbcbcbcz' p /a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' # matches in ruby 3.2.2 p /a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz' p /a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz' ~~~ Adding backref (to disable optimization) makes them match. ~~~ruby p /()\1a((.|.)|bc){,4}z/.match? 'abcbcbcbcz' p /()\1a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' p /()\1a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz' p /()\1a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz' ~~~ Found in this script https://gist.github.com/tompng/aa0706a181e9187bd79e8cec5a5f3c97 -- https://bugs.ruby-lang.org/