From: Louis J Scoras Date: 2006-05-13T00:20:57+09:00 Subject: Re: Is there a method for incrementing string names?!? 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.