On Thu, Jan 30, 2014 at 12:24 AM, tamouse pontiki
<tamouse.lists / gmail.com> wrote:
>
>
>
> On Mon, Jan 27, 2014 at 9:06 AM, Jes=FAs Gabriel y Gal=E1n
> <jgabrielygalan / gmail.com> wrote:
>>
>> On Mon, Jan 27, 2014 at 3:47 PM, Arup Rakshit <lists / ruby-forum.com>
>> wrote:
>> > Joel Pearson wrote in post #1134542:
>> >> You're only looking for 1 match group. If you use 2 match groups, you
>> >> can look for the second one:
>> >>
>> >> message[/(#\w+).*(#\w+)/,2]
>> >> =3D> "#Ram"
>> >
>> > But here http://rubular.com/r/rZgnEP3hSP I can see the matches as 1,2.
>> > Why not then String#[] doesn't work that way. Still I am in a confusio=
n.
>> >
>> > --
>> > Posted via http://www.ruby-forum.com/.
>>
>> I'm guessing that Rubular is checking for all the matches across the
>> string, kind of like what String#scan does:
>>
>> 2.0.0p195 :001 > message =3D '#bat with some #Ram'
>>  =3D> "#bat with some #Ram"
>> 2.0.0p195 :002 > message.scan(/(#\w+)/)
>>  =3D> [["#bat"], ["#Ram"]]
>
>
> Not exactly sure why you'd want the subgrouping with scan as it's creatin=
g a
> nested array here.
>
> [6] pry(main)> message.scan(/#\w+/) # =3D> ["#bat", "#Ram"]

You are right, I just copy pasted the original Regexp.

Jesus.