J
Jamis Buck
Here's an oddity I recently came across in a unit test. Identical
regexps declared with /.../ will be equivilent to each other, but not to
the same regexps created with %r{...}:
$ ruby -ve 'p( /\/blah/ == /\/blah/ )'
ruby 1.8.2 (2004-07-29) [i686-linux]
true
$ ruby -ve 'p( %r{/blah} == %r{/blah} )'
ruby 1.8.2 (2004-07-29) [i686-linux]
true
$ ruby -ve 'p( /\/blah/ == %r{/blah} )'
ruby 1.8.2 (2004-07-29) [i686-linux]
false
This appears to only be the case when there is a forward slash in the
regexp. In other words:
$ ruby -ve 'p( /blah/ == %r{blah} )'
ruby 1.8.2 (2004-07-29) [i686-linux]
true
Can anyone else confirm this? Can anyone *explain* it? Or is this a bug?
- Jamis
regexps declared with /.../ will be equivilent to each other, but not to
the same regexps created with %r{...}:
$ ruby -ve 'p( /\/blah/ == /\/blah/ )'
ruby 1.8.2 (2004-07-29) [i686-linux]
true
$ ruby -ve 'p( %r{/blah} == %r{/blah} )'
ruby 1.8.2 (2004-07-29) [i686-linux]
true
$ ruby -ve 'p( /\/blah/ == %r{/blah} )'
ruby 1.8.2 (2004-07-29) [i686-linux]
false
This appears to only be the case when there is a forward slash in the
regexp. In other words:
$ ruby -ve 'p( /blah/ == %r{blah} )'
ruby 1.8.2 (2004-07-29) [i686-linux]
true
Can anyone else confirm this? Can anyone *explain* it? Or is this a bug?
- Jamis