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
Updated by dentarg (Patrik Ragnarsson) 10 months ago
Updated by tompng (tomoya ishida) 10 months ago
Not same. https://bugs.ruby-lang.org/issues/20083 is related to regexp optimization from ruby 3.2.
This issue is not because it's same result in older ruby version 3.0 and 3.1
Actions
Like0
Like0Like0