Thank you!


Brian Candler wrote:
>> any ideas?
> 
> Here's a simple recursive expansion, with a block callback for each 
> sequence found.
> 
> def expand_seq(src, &blk)
>   if src =~ /\A(.*?)\[(.*?)\](.*)\z/m
>     prefix, chars, suffix = $1, $2, $3
>     chars.split(//).each do |ch|
>       expand_seq(prefix + ch + suffix, &blk)
>     end
>   else
>     yield src
>   end
> end
> 
> expand_seq "ac[ta]cct[gt]c" do |seq|
>   puts seq
> end

-- 
Posted via http://www.ruby-forum.com/.