Regex question

[code]
irb(main):113:0> /l{2}x/ =~ 'llx'
=> 0
irb(main):109:0> /(lo){2}/ =~ 'lolo'
=> 0
irb(main):110:0> /(lo){2}x/ =~ 'lolox'
=> nil
irb(main):111:0> /(?:lo){2}x/ =~ 'lolox'
=> 0
[/code]

Note the third command returned nil but the fourth worked, any ideas?

[code]
$ ruby -v
ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]
[/code]

···

--
Posted via http://www.ruby-forum.com/.

Katz Bo wrote:

[code]
irb(main):113:0> /l{2}x/ =~ 'llx'
=> 0
irb(main):109:0> /(lo){2}/ =~ 'lolo'
=> 0
irb(main):110:0> /(lo){2}x/ =~ 'lolox'
=> nil
irb(main):111:0> /(?:lo){2}x/ =~ 'lolox'
=> 0
[/code]

Note the third command returned nil but the fourth worked, any ideas?

[code]
$ ruby -v
ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]
[/code]

irb(main):001:0> /(lo){2}x/ =~ 'lolox'
=> 0
irb(main):002:0> RUBY_VERSION
=> "1.8.7"

···

--

Seems like a bug.

irb(main):110:0> /(lo){2,3}x/ =~ 'lolox'
irb(main):110:0> /(lo){1,2}x/ =~ 'lolox'
irb(main):110:0> /(lo){2,}x/ =~ 'lolox'
irb(main):110:0> /(lo){,2}x/ =~ 'lolox'

all work for me on ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]

It's just {2} that doesn't work.

···

On Sun, Dec 20, 2009 at 10:05 AM, W. James <w_a_x_man@yahoo.com> wrote:

Katz Bo wrote:

[code]
irb(main):113:0> /l{2}x/ =~ 'llx'
=> 0
irb(main):109:0> /(lo){2}/ =~ 'lolo'
=> 0
irb(main):110:0> /(lo){2}x/ =~ 'lolox'
=> nil
irb(main):111:0> /(?:lo){2}x/ =~ 'lolox'
=> 0
[/code]

Note the third command returned nil but the fourth worked, any ideas?

--
Paul Smith
http://www.nomadicfun.co.uk

paul@pollyandpaul.co.uk

Paul Smith wrote:

Seems like a bug.

It's just {2} that doesn't work.

Same for me. I actually had tried what you tried too. Also, {2,2} won't
work either.

···

--
Posted via http://www.ruby-forum.com/\.

Katz Bo wrote:

Same for me. I actually had tried what you tried too. Also, {2,2} won't
work either.

Sorry for double posting, post too quick.
Yet another thing is, {1} works:

/(lo){1}x/ =~ 'lololox' # => 4
/(lo){2}x/ =~ 'lololox' # => nil
/(lo){3}x/ =~ 'lololox' # => nil

···

--
Posted via http://www.ruby-forum.com/\.

That's definitively a bug! => http://redmine.ruby-lang.org/

Kind regards

  robert

···

On 20.12.2009 12:37, Katz Bo wrote:

Katz Bo wrote:

Same for me. I actually had tried what you tried too. Also, {2,2} won't work either.

Sorry for double posting, post too quick.
Yet another thing is, {1} works:

/(lo){1}x/ =~ 'lololox' # => 4
/(lo){2}x/ =~ 'lololox' # => nil
/(lo){3}x/ =~ 'lololox' # => nil

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/