String#index/include limitation in number of characters

Do you understand why the last include gives false ?? It seems that the
limit is 24 characters, is it a bug ?

irb(main):001:0>
s=“asdfasdfasdfasdfasdfppppppppppppppppppppppppasdfasdf”
=> “asdfasdfasdfasdfasdfppppppppppppppppppppppppasdfasdf”
irb(main):002:0> s1=“pppppppppppppppppppppppp”
=> “pppppppppppppppppppppppp”
irb(main):003:0> s.include?(s1)
=> true
irb(main):004:0> s1=“ppppppppppppppppppppppppasdf”
=> “ppppppppppppppppppppppppasdf”
irb(main):005:0> s.include?(s1)
=> false

In message [email protected], Eu Fe
writes:

Do you understand why the last include gives false ?? It seems that the
limit is 24 characters, is it a bug ?

I don’t think the limit is 24 characters.

=> false
I cannot reproduce this. I cut and paste it:

irb(main):007:0>
s=“asdfasdfasdfasdfasdfppppppppppppppppppppppppasdfasdf”
=> “asdfasdfasdfasdfasdfppppppppppppppppppppppppasdfasdf”
irb(main):008:0> s1=“ppppppppppppppppppppppppasdf”
=> “ppppppppppppppppppppppppasdf”
irb(main):009:0> s.include?(s1)
=> true

-s

Maybe my platform or interpreter ??? That’s really weird:
irb 0.9(02/07/03)
Linux 2.6.9-34.ELsmp #1 SMP Thu Mar 9 06:23:23 GMT 2006 x86_64 x86_64
x86_64 GNU/Linux

ruby 1.8.1 (2003-12-25) [x86_64-linux-gnu]

OK I upgraded to ruby 1.8.6 with irb 9.5 it solves the problem.

It seems to be a bug in the previous version !

On Sat, May 19, 2007 at 07:03:50AM +0900, Eu Fe wrote:

OK I upgraded to ruby 1.8.6 with irb 9.5 it solves the problem.

It seems to be a bug in the previous version !

Yep, don’t use the one which comes with Red Hat/CentOS. It breaks with
all
sorts of things.

There’s a 1.8.5 pre-built package in the CentOS ‘testing’ directory
which
works well.

Regards,

Brian.

On Sat, May 19, 2007 at 06:08:02AM +0900, Eu Fe wrote:

irb(main):004:0> s1=“ppppppppppppppppppppppppasdf”
=> “ppppppppppppppppppppppppasdf”
irb(main):005:0> s.include?(s1)
=> false

I get ‘true’ in both cases. I am using the package supplied with Ubuntu
Linux 6.06, which gives RUBY_VERSION as 1.8.4

What platform and ruby version are you using?