Project

General

Profile

Actions

Feature #5484

closed

regexp comparison bug

Added by ddebernardy (Denis de Bernardy) about 13 years ago. Updated over 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:40364]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0