Actions
Bug #20097
openRegexp#match? with empty capture group repeat is inconsistent
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
Description
It sometimes matches and sometimes does not, depend on repeat quantifier number.
# 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.
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
Actions
Like0
Like0Like0