From: eden li Date: 2007-05-02T13:12:27+09:00 Subject: Re: testing and assigning with regexp's str = $& if str =~ /something/ Although, running this when str == '' is pretty useless. On May 2, 10:20 am, "Mike Steiner" wrote: > I'm new to Ruby, and in a little program I'm writing, I have code like this: > > str = '' > if /something/.match(str) > str = /something/.match(str)[1] > end > > Is there a more elegant way to do this? > > Mike Steiner