This is a definite step in the right direction and I appreciate your
assistance Jesus.
So I have a fieldname in a UI which is named Hostnames:
Within the hostname field, it could have a single host named
svr10.domain.local or it could have a range like
svr.10.domain.local,svr[100..103].domain.local.
Essentially what I am trying to do is to get that hostname field in my
script and for each individual host and/or a range of hosts then do a
specific command or go through my work flow.
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]}"}
Here's my version:
str = "svr[100..130].domain.local"
range_pattern = /
\[ #a literal opening bracket
(\d+) #capture a series of one or more digits
[.]{2} #two literal periods
(\d+) #capture a series of one or more digits
\] #a literal closing bracket
/xms
This is a definite step in the right direction and I appreciate your
assistance Jesus/7stud
So I have a fieldname in a UI which is named Hostnames:
Within the hostname field, it could have a single host named
svr10.domain.local or it could have a range like
svr.10.domain.local,svr[100..103].domain.local.
Essentially what I am trying to do is to get that hostname field in my
script and for each individual host and/or a range of hosts then do a
specific command or go through my work flow.
nodes.each do |node|
m = node.match(/(.*?)\[(\d+)\.\.(\d+)\](.*)/)
if m
(m[2].to_i..m[3].to_i).each {|num|
do_something_with("#{m[1]}#{num}#{m[4]}")}
else
do_something_with(node)
end
end
This will call do_something_with passing either each expanded server
name or the original string if it doesn't match the regular
expression.
Jesus.
···
On Fri, Apr 15, 2011 at 11:54 PM, Richard Sandoval <skolopen@yahoo.com> wrote: