From: Rick DeNatale Date: 2006-10-25T11:33:18+09:00 Subject: Re: DRY fanatics? On 10/24/06, Gennady Bystritsky wrote: > Rick DeNatale wrote: > > On 10/24/06, Martin DeMello wrote: > >> On 10/22/06, Giles Bowkett wrote: > >>> Anybody know a way to make this DRYer? > >>> > >>> when /^([A-Za-z0-9,]+), '([^']+)', '([^']+)', '([^']+)'/ > >> > >> grp = %{ '([^']+)'} > >> rx = /^([A-Za-z0-9,]+),#{grp},#{grp},#{grp}/ > > > > Still too WET! > > > > grp = %{,'([^']+)'} > > rx = /^([A-Za-z0-9,]+)#{grp*3}/ > > > > Now, can someone how to make this DRYer? > > rx = Regexp.new ['^([\w,]+)', *["'(.+?)'"]*3].join(', ') > > ;-) > > (assuming '_' in the first field is acceptable) NO NO NO! I meant make x = 111 DRYER, all that needless repetition of the digit 1! --- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/