[ruby-core:111465] [Ruby master Bug#19273] [Regexp] regexp does not does not match expected

Issue #19273 has been reported by taichi730 (Taichi Ishitani). ---------------------------------------- Bug #19273: [Regexp] regexp does not does not match expected https://bugs.ruby-lang.org/issues/19273 * Author: taichi730 (Taichi Ishitani) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/

Issue #19273 has been updated by mrkn (Kenta Murata). I performed git bisect and found the first bad commit is 37613fea1657b1a0732501657275bc03e8e0ebc4. ---------------------------------------- Bug #19273: [Regexp] regexp does not does not match expected https://bugs.ruby-lang.org/issues/19273#change-100837 * Author: taichi730 (Taichi Ishitani) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/

Issue #19273 has been updated by mrkn (Kenta Murata). Assignee set to make_now_just (Hiroya Fujinami) ---------------------------------------- Bug #19273: [Regexp] regexp does not does not match expected https://bugs.ruby-lang.org/issues/19273#change-100838 * Author: taichi730 (Taichi Ishitani) * Status: Open * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/

Issue #19273 has been updated by taichi730 (Taichi Ishitani). This pattern shows a binary|decimal|hexadecimal value splitted by : character. decimal only and decimal|hexadecimal patterns match expectedly. decimal only pattern: ``` irb(main):019:0> pattern = /(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)(?::(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)){0,3}/ => /(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)(?::(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)){0,3}/ irb(main):020:0> "10:0:0".match(pattern) => #<MatchData "10:0:0"> ``` decimal|hex pattern: ``` irb(main):021:0> = /(?-mix:(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?-mix:[+-]?(?:[1-irb(main):021:0> pattern = /(?-mix:(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ => /(?-mix:(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?-mix:[+-]?(?:[1-9]_?(?:\d_?... irb(main):022:0> "10:0:0".match(pattern) => #<MatchData "10:0:0"> ``` But binary|decimal pattern does not. ``` irb(main):023:0> pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d))){0,3}/ => /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[0... irb(main):024:0> "10:0:0".match(pattern) => #<MatchData "10"> ``` ---------------------------------------- Bug #19273: [Regexp] regexp does not does not match expected https://bugs.ruby-lang.org/issues/19273#change-100839 * Author: taichi730 (Taichi Ishitani) * Status: Open * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/

Issue #19273 has been updated by taichi730 (Taichi Ishitani). Pattern using `*` instead of `{0,3}` matches expactedly. ``` irb(main):027:0> pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*)))*/ => /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mi... irb(main):028:0> "10:0:0".match(pattern) => #<MatchData "10:0:0"> ``` ---------------------------------------- Bug #19273: [Regexp] regexp does not does not match expected https://bugs.ruby-lang.org/issues/19273#change-100840 * Author: taichi730 (Taichi Ishitani) * Status: Open * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/

Issue #19273 has been updated by make_now_just (Hiroya Fujinami). PR [#7035](https://github.com/ruby/ruby/pull/7035) for fixing the bug is created. ---------------------------------------- Bug #19273: [Regexp] regexp does not match expected https://bugs.ruby-lang.org/issues/19273#change-100843 * Author: taichi730 (Taichi Ishitani) * Status: Open * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/

Issue #19273 has been updated by nagachika (Tomoyuki Chikanaga). Status changed from Open to Closed Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED merged at b726d60c986bf951d13e7a2ab5f5e58f58657b03 ---------------------------------------- Bug #19273: [Regexp] regexp does not match expected https://bugs.ruby-lang.org/issues/19273#change-100846 * Author: taichi730 (Taichi Ishitani) * Status: Closed * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/

Issue #19273 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 a7d467a792c644a7260d6560ea2002fdb8ff6de3 merged revision(s) b726d60c986bf951d13e7a2ab5f5e58f58657b03. ---------------------------------------- Bug #19273: [Regexp] regexp does not match expected https://bugs.ruby-lang.org/issues/19273#change-100870 * Author: taichi730 (Taichi Ishitani) * Status: Closed * Priority: Normal * Assignee: make_now_just (Hiroya Fujinami) * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux] * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE ---------------------------------------- A regexp pattern does not match expected with Ruby 3.2. Ruby 3.2 ``` ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".mathc(pattern) #=> #<MatchData "10"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` String "10.0.0" is only partially matched but not all of it. Ruby 3.1.0: ```ruby pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/ "10:0:0".match(pattern) #=> #<MatchData "10:0:0"> "0:0:0".match(pattern) #=> #<MatchData "0:0:0"> ``` Both strings matches with the regexp wholy. -- https://bugs.ruby-lang.org/
participants (5)
-
make_now_just (Hiroya Fujinami)
-
mrkn (Kenta Murata)
-
nagachika (Tomoyuki Chikanaga)
-
naruse (Yui NARUSE)
-
taichi730 (Taichi Ishitani)