From: Human Dunnil Date: 2006-05-13T00:36:33+09:00 Subject: Re: Is there a method for incrementing string names?!? My friends ask me why you love Ruby! that's becasue of you guys. ; ) Thanks On 5/12/06, Louis J Scoras wrote: > On 5/12/06, C Erler wrote: > > Here's a method to do it : > > > > def inc name > > parts = name.scan(/^(.*\D)(\d+)$/).first > > if parts.nil? > > "#{name}1" > > else > > "#{parts.first}#{parts.last.to_i + 1}" > > end > > end > > > > Quite right. My regex should have been anchored: > > /\A(\d*)(.*)/ > > > -- > Lou. > >