Actions
Bug #21291
openpossible bug with /m regexp and $ based on input
Description
reported in discord by the.unnamed user:
#!/usr/bin/env -S ruby -vw
# => ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [arm64-darwin24]
p "a\n" =~ /$./m
# => 1
p "a\n" =~ /$.*/m
# => 1
p "aa\n" =~ /$./m
# => 2
p "aa\n" =~ /$.*/m # !!!
# => nil
p "aa\n" =~ /$[\S\s]*/m
# => 2
goes back to at least 3.2.8
Updated by nobu (Nobuyoshi Nakada) 7 days ago
1.8 prints 2 but 1.9 and later print nil.
Updated by nobu (Nobuyoshi Nakada) 7 days ago
- Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED
Updated by dodecadaniel (Daniel Colson) 7 days ago
Possible fix: https://github.com/ruby/ruby/pull/13200
Actions
Like0
Like0Like0Like0