From: "mame (Yusuke Endoh)" Date: 2012-11-05T20:38:19+09:00 Subject: [ruby-core:48897] [ruby-trunk - Bug #7042][Rejected] String#=~ is not equal to Regexp#=~ Issue #7042 has been updated by mame (Yusuke Endoh). Status changed from Open to Rejected Because this is a kind of assignment, the value is in the right side and the variable is in the left side... we thought. This is actually intentional. Closing. You can open a feature request to add a pattern to regexp assignment, if you wish. -- Yusuke Endoh ---------------------------------------- Bug #7042: String#=~ is not equal to Regexp#=~ https://bugs.ruby-lang.org/issues/7042#change-32392 Author: Hanmac (Hans Mackowiak) Status: Rejected 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" =~ /(?\d+):(?\d+) (?A|P)M/; p hour,minute,pm # works not /(?\d+):(?\d+) (?A|P)M/ =~ "6:15 AM"; p hour,minute,pm # works i wonder why is that so ? -- http://bugs.ruby-lang.org/