2010/11/8 Chandu80 <chandu.shenoy / gmail.com>:
> Hello All,
> I want to write a script by which I can open up a text file,scan
> through it,find the line which contains the word 'test_site',get the
> IP address corresponding to that word, replace that IP with another IP
> address and then save and close the file.
> Are there any commands in Ruby to identify IP address from a string?
>

maybe a regex is useful, though that's not rigorous enough.

irb(main):001:0> s="ip addr:12.34.56.78"
=> "ip addr:12.34.56.78"

irb(main):002:0> s.scan /\d+\.\d+\.\d+\.\d+/
=> ["12.34.56.78"]


-- 
Kind regards,
  Zuer (ΑΔΡΉ)