Project

General

Profile

Actions

Bug #22429

open

regex empty capture group in a counted loop prevents a match

Bug #22429: regex empty capture group in a counted loop prevents a match

Added by robertmorelli (Robert Morelli) about 16 hours ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.7 (2026-09-15 revision 229531a6cf) +PRISM [arm64-darwin27]
[ruby-core:127080]

Description

repro:

/\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.

No data to display

Actions

Also available in: PDF Atom