From: "matz (Yukihiro Matsumoto) via ruby-core" Date: 2026-11-19T05:14:44+00:00 Subject: [ruby-core:127605] [Ruby Bug#22429] regex empty capture group in a counted loop prevents a match Issue #22429 has been updated by matz (Yukihiro Matsumoto). I agree this is a bug. An empty capture group should not change whether the pattern matches, and all three patterns should return true. Please fix it. Matz. ---------------------------------------- Bug #22429: regex empty capture group in a counted loop prevents a match https://bugs.ruby-lang.org/issues/22429#change-120125 * Author: robertmorelli (Robert Morelli) * Status: Open * ruby -v: ruby 4.0.7 (2026-09-15 revision 229531a6cf) +PRISM [arm64-darwin27] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- repro: ```ruby /\A(?:(){1,2}?a)+\z/.match?("aa") # false /\A(?:(?:){1,2}?a)+\z/.match?("aa") # true /\A(?:(){1,2}a)+\z/.match?("aa") # true ``` An empty capture `()` behaves differently from `(?:)`. Perl, Python and Oniguruma 6.9.10 return true for all three. -- 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/lists/ruby-core.ml.ruby-lang.org/