Project

General

Profile

Actions

Bug #7042

closed

String#=~ is not equal to Regexp#=~

Added by Hanmac (Hans Mackowiak) over 11 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Backport:
[ruby-core:47628]

Description

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 ?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0