From: Gennady Date: 2004-06-11T08:16:24+09:00 Subject: Re: String#scan strangeness Simon Strandgaard wrote: > On Friday 11 June 2004 00:43, Gennady wrote: > >>irb(main):001:0> a = "a b c d " >>=> "a b c d " >>irb(main):002:0> a.scan %r{((\S+\s+){2,2})} ^^^^^^^ ^^^^^^^^^^^^^^ These are sub-captures >>ACTUAL => [["a b ", "b "], ["c d ", "d "]] >>I EXPECT => [["a b ", "a ", "b "], ["c d ", "c ", "d "]] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ And this is scan's result presented by irb > > ^^^^ ^^^^ > these are not subcaptures > and are thus not being captured. > you need parentesis in order to capture them > > -- > Simon Strandgaard > >