
Issue #20246 has been updated by make_now_just (Hiroya Fujinami). This is a bug in regex optimization. Some optimizations have been disabled for memoization since 3.3.0. Therefore, another optimization was enabled, and that bug has surfaced. By complicating the content of the first loop, we can confirm that the same problem occurs in 3.2.0 and earlier. ``` $ ruby --version ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22] $ ruby -e 'p "1.2.3"[/((?:\d|foo|bar)+)(\.\g<1>){2}/]' nil ``` [#9897](https://github.com/ruby/ruby/pull/9897) will fix this bug. ---------------------------------------- Bug #20246: Unexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0 https://bugs.ruby-lang.org/issues/20246#change-106644 * Author: bestwebua (Vladislav Trotsenko) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Hello! A few days ago, after migration on 3.3.0 I have faced with issue inside subexpression calls. An expected result on Ruby up to 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => "1.2.3" ``` An actual result on Ruby 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => nil ``` -- https://bugs.ruby-lang.org/