[ruby-core:112683] [Ruby master Bug#19476] Regexp unexpected match

Issue #19476 has been reported by andreccosta (André Costa). ---------------------------------------- Bug #19476: Regexp unexpected match https://bugs.ruby-lang.org/issues/19476 * Author: andreccosta (André Costa) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Ruby 3.2.1: ```ruby
RUBY_VERSION => "3.2.1" irb(main):011:0> "123456789".match(/(\(?\d-?\)?){6,15}/) => #<MatchData "123456" 1:"6"> irb(main):012:0> "123456789".match(/(\d-?\)?){6,}/) => #<MatchData "123456" 1:"6">
Ruby 3.1.3:
``` ruby
> RUBY_VERSION
=> "3.1.3"
> "123456789".match(/(\(?\d-?\)?){6,15}/)
=> #<MatchData "123456789" 1:"9">
> "123456789".match(/(\d-?\)?){6,}/)
=> #<MatchData "123456789" 1:"9">

Issue #19476 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Open to Assigned Assignee set to make_now_just (Hiroya Fujinami) ---------------------------------------- Bug #19476: Regexp unexpected partial match https://bugs.ruby-lang.org/issues/19476#change-102160 * Author: andreccosta (André Costa) * Status: Assigned * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- This regular expression does not have the expected match since Ruby 3.2. Ruby 3.2.1: ```ruby
RUBY_VERSION => "3.2.1" "123456789".match(/(\(?\d-?\)?){6,15}/) => #<MatchData "123456" 1:"6"> "123456789".match(/(\d-?\)?){6,}/) => #<MatchData "123456" 1:"6">
Results in a partial match even though the specified quantifiers should allow matching the whole string.
Ruby 3.1.3:
``` ruby
> RUBY_VERSION
=> "3.1.3"
> "123456789".match(/(\(?\d-?\)?){6,15}/)
=> #<MatchData "123456789" 1:"9">
> "123456789".match(/(\d-?\)?){6,}/)
=> #<MatchData "123456789" 1:"9">
Which is the outcome for both patterns in previous versions. -- https://bugs.ruby-lang.org/

Issue #19476 has been updated by naruse (Yui NARUSE). Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE ruby_3_2 ad6fe84dfa6935bd6e2c3ef3ee36bed4e8627d0b merged revision(s) dddc542e9b61b292d80a96d0d0efbbf58719e3be. ---------------------------------------- Bug #19476: Regexp unexpected partial match https://bugs.ruby-lang.org/issues/19476#change-102503 * Author: andreccosta (André Costa) * Status: Closed * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22] * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE ---------------------------------------- This regular expression does not have the expected match since Ruby 3.2. Ruby 3.2.1: ```ruby
RUBY_VERSION => "3.2.1" "123456789".match(/(\(?\d-?\)?){6,15}/) => #<MatchData "123456" 1:"6"> "123456789".match(/(\d-?\)?){6,}/) => #<MatchData "123456" 1:"6">
Results in a partial match even though the specified quantifiers should allow matching the whole string.
Ruby 3.1.3:
``` ruby
> RUBY_VERSION
=> "3.1.3"
> "123456789".match(/(\(?\d-?\)?){6,15}/)
=> #<MatchData "123456789" 1:"9">
> "123456789".match(/(\d-?\)?){6,}/)
=> #<MatchData "123456789" 1:"9">
Which is the outcome for both patterns in previous versions. -- https://bugs.ruby-lang.org/
participants (3)
-
andreccosta
-
hsbt (Hiroshi SHIBATA)
-
naruse (Yui NARUSE)