Issue #5484 has been reported by Denis de Bernardy.

----------------------------------------
Bug #5484: regexp comparison bug
http://redmine.ruby-lang.org/issues/5484

Author: Denis de Bernardy
Status: Open
Priority: Low
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10]


Based on ri Regexp.eql?:

Equality---Two regexps are equal if their patterns are identical, they have
the same character set code, and their casefold? values are the same.

  /abc/  == /abc/x   #=> false
  /abc/  == /abc/i   #=> false
  /abc/  == /abc/n   #=> false
  /abc/u == /abc/n   #=> false

However:

>> a = Regexp.new("/foo")
=> /\/foo/
>> b = /\/foo/
=> /\/foo/
>> a == b
=> false

The only meaningful difference between the two is the exact source:

>> a.source
=> "/foo"
>> b.source
=> "\\/foo"

But I'd argue that a's source should be normalized to that of b, or vice-versa, since their string representations are identical.


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