Issue #7042 has been updated by stomar (Marcus Stollsteimer).


=begin
...and further down in the Regexp docs:

"This assignment is implemented in the Ruby parser. The parser detects ???regexp-literal =~ expression??? for the assignment. The regexp must be a literal without interpolation and placed at left hand side."

"The assignment does not occur if the regexp is not a literal."
=end

----------------------------------------
Bug #7042: String#=~ is not equal to Regexp#=~
https://bugs.ruby-lang.org/issues/7042#change-29689

Author: Hanmac (Hans Mackowiak)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


i found out that string =~ regexp is not equal to regexp =~ string
when you use named captures:

"6:15 PM" =~ /(?<hour>\d+):(?<minute>\d+) (?<pm>A|P)M/; p hour,minute,pm # works not
/(?<hour>\d+):(?<minute>\d+) (?<pm>A|P)M/ =~ "6:15 AM"; p hour,minute,pm # works

i wonder why is that so ?


-- 
http://bugs.ruby-lang.org/