From: jackster the jackle Date: 2009-12-01T07:39:42+09:00 Subject: Re: Searching Text for Multiple Matches Thanks Roger. I am currently iterating through each line of text and matching on any lines that either have "IP Address" or "Default Gateway" in them and grabbing the IP addresses and assigning them to variables. The problem is, the first IP address I get seems to disapear toward the end of the script and I can't figure out why....perhaps because I'm using "elsif"? here is the code: ipconf = `ipconfig` ipconf.each do |x| if x[/IP\sAdd*/] x.scan(/\s*IP\sAddress.*\:\s([1-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+$/) ip = $1 puts "ip addr: " + $1.to_s ## THIS PRINTS OUT FINE elsif x[/Def*/] puts "XXXXX IP: #{ip}" x.scan(/\s*Default\sGateway.*\:\s([1-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+$/) def_gate = $1 puts "Default Gateway: "+$1.to_s ## THIS PRINTS OUT FINE puts "Print IP address again: #{ip_addr}" ### THIS HAS NO VALUE end end I think I need to somehow combine the "if" and "elsif" statements so I'm not using "or" and this way the ip_addr variable will hold it's value? thanks jack -- Posted via http://www.ruby-forum.com/.