From: "Jesús Gabriel y Galán" Date: 2011-04-16T01:41:45+09:00 Subject: Re: Extract a range i.e. svr[100..130] ? On Fri, Apr 15, 2011 at 6:08 PM, Richard Sandoval wrote: > What best method could extract the range of a given list of servers? > > I have a field name on a UI that contains a list of servers and it can > be a range such as > svr[100..130].domain.local,prod[10..13].otherdomain.local. > > > What would be my best approach to single each one of those nodes out to > iterate through? Sorry, if I didn't understand this well. You have a string containing "svr[100..130].domain.local" and you want: svr100.domain.local svr101.domain.local .... svr130.domain.local ? If that's the case, then this might work: a = "svr[100..130].domain.local" m = a.match(/(.*?)\[(\d+)\.\.(\d+)\](.*)/) (m[2].to_i..m[3].to_i).each {|num| puts "#{m[1]}#{num}#{m[4]}"} => svr100.domain.local svr101.domain.local svr102.domain.local [...snip...] svr129.domain.local svr130.domain.local Jesus