From: Daniel Finnie Date: 2007-01-11T05:26:23+09:00 Subject: Re: [QUIZ] Word Blender (#108) It does hurt readability, however, if it is in a variable then the readability goes up a little. regex is probably a bad name, tho. noRepeats3-6Letters = ... dict.scan(noRepeats3-6Letters) Even better would be a method that creates a regex for an arbitrary length so it's ugliness is never shown in its entirety in one concentrated spot. The king of readability, I admit, doesn't involve /regexp?e[ns]/ at all. class Array def uniq? (uniq == self) end end class String def letters split(//) end end dict.select {|x| x.length.between?(3, 6) && x.letters.uniq?} dan James Edward Gray II wrote: > On Jan 7, 2007, at 6:41 PM, Daniel Finnie wrote: > >> Oops, that doesn't match {3,6} just {6}. >> >> >> regex = >> /^([a-z])(?!\1)([a-z])(?!\1|\2)([a-z])(?:(?!\1|\2|\3)([a-z]))?(?:(?!\1|\2|\3|\4)([a-z]))?(?:(?!\1|\2|\3|\4|\5)([a-z]))?$/ >> > > Wow. That's darn clever, but probably over abusing regular expressions > a bit, don't you think? ;) > > James Edward Gray II > >