From: Tobias Reif Date: 2002-02-07T19:15:34+09:00 Subject: Re: shuffle (all possible sequences) I wrote: (I'll shut up for today :) ) > I'm sorry; it would be way better to have a boolean method, like: > "abc".consists_of?("abc") # -> true > "acb".consists_of?("abc") # -> true > "bac".consists_of?("abc") # -> true > "bca".consists_of?("abc") # -> true > > And then, how can I say > > word_list = ['foo', 'bca'] > word_list.include? word_consisting_of('abc') > # => true This seems to do the trick: class String def consists_of word self =~ /[#{word}]{#{word.length}}/ end end class Array def get_words_consisting_of word select do |item| item.consists_of word end end end Tobi -- * peace&love. * http://www.pinkjuice.com/