Actions
Bug #19273
closed[Regexp] regexp does not match expected
Bug #19273:
[Regexp] regexp does not match expected
Description
A regexp pattern does not match expected with Ruby 3.2.
Ruby 3.2
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:
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.
Actions