📚

[Bug #20083] String#match? behaving inconsistently with Ruby 3.3.0

2024/01/11に公開

[Bug #20083] String#match? behaving inconsistently with Ruby 3.3.0

  • 同様に Ruby 3.3.0 で正規表現がおかしいというバグ報告
  • 以下のコードは Ruby 3.2.2 では全て true になるが Ruby 3.3.0 の場合は false になるケースが存在している
# /i のときに再現する
pattern = /([\s]*ABC)$/i # or /(\s*ABC)/i

# Ruby 3.3.0 の実行結果
p "1ABC".match?(pattern) # => true
p "12ABC".match?(pattern) # => true
p "123ABC".match?(pattern) # => true
p "1231ABC".match?(pattern) # => true
p "12312ABC".match?(pattern) # => false
p "123123ABC".match?(pattern) # => false
p "1231231ABC".match?(pattern) # => true
p "12312312ABC".match?(pattern) # => true
p "123123123ABC".match?(pattern) # => false
p "1231231231ABC".match?(pattern) # => false
p "12312312312ABC".match?(pattern) # => true
p "123123123123ABC".match?(pattern) # => true
p "1231231231231ABC".match?(pattern) # => false
GitHubで編集を提案

Discussion