From: Giampiero Zanchi Date: 2009-02-11T23:41:43+09:00 Subject: Re: Method to get string combinations my_text = "This {is|was} a {good|nice} day" r = /\{(.*?)\}/ elem = my_text.split(r).map! {|x| x.split("|")} comb = [] elem.each_index do |i| if comb.empty? elem[i].each {|x| comb << x} else comb_size = comb.size 0...comb_size.times do |j| elem[i].each { |x| s = comb.first + x ; comb.push(s) } comb.shift end end end p comb -- Posted via http://www.ruby-forum.com/.