# Re: DRY fanatics?

**URL:** <https://www.ruby-forum.com/t/re-dry-fanatics/73521>\
**Category:** Ruby\
**Created:** [October 25, 2006, 1:45am UTC](https://www.ruby-forum.com/t/re-dry-fanatics/73521 "2006-10-25T01:45:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [October 25, 2006, 1:45am UTC](https://www.ruby-forum.com/t/re-dry-fanatics/73521/1 "2006-10-25T01:45:28Z")

</div>

Rick DeNatale wrote:

> 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)

Gennady.

---

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [October 25, 2006, 2:23am UTC](https://www.ruby-forum.com/t/re-dry-fanatics/73521/2 "2006-10-25T02:23:31Z")

</div>

> > 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)

Beautiful! Or wait, did I mean beautiful? Maybe I meant sick and wrong.

But you know what, just to taunt you Perlish types…

The initial regex I posted was actually wrong.

It was this:

when /^([A-Za-z0-9,]+), ‘([^’]+)’, ‘([^’]+)’, ‘([^’]+)’/

It needed to be this instead:

when /^([A-Za-z0-9,]+), ‘([^’]+)’, ‘([^’]+)’, ‘([^’]\*)’/

Bet you can’t DRY that!

---

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [October 25, 2006, 4:33am UTC](https://www.ruby-forum.com/t/re-dry-fanatics/73521/3 "2006-10-25T04:33:46Z")

</div>

On 10/24/06, Gennady B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Still too WET!  
> > (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/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [October 25, 2006, 5:27am UTC](https://www.ruby-forum.com/t/re-dry-fanatics/73521/4 "2006-10-25T05:27:30Z")

</div>

> NO NO NO!
> 
> I meant make
> 
> x = 111
> 
> DRYER, all that needless repetition of the digit 1!

lol

sorry, flew over my head.
