Skip to content

Instantly share code, notes, and snippets.

Created April 15, 2016 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f09cdcbfb7d574e45a490135649b5313 to your computer and use it in GitHub Desktop.
Save anonymous/f09cdcbfb7d574e45a490135649b5313 to your computer and use it in GitHub Desktop.
Regex for extracting IP
output = "IP address : 192.168.9.2
NetBIOS name : DOMAIN-DC-2
DNS name : here-is-1-dns.name.com
IP address : ffff:eeff:20ff:480:ffff:4461:87aa:ce7e
IP address : 192.168.9.7
NetBIOS name : DOMAIN-DC-5
DNS name : here-is-2-dns.name.com
IP address : ffff:eeff:20ff:480:ffff:4461:87aa:fdce
IP address : 192.168.0.1
NetBIOS name : DOMAIN-DC-4
DNS name : here-is-3-dns.name.com
"
dc_list = output.split(/\n/)
@saved_dc = dc_list[0].split(/: */).last.chomp
puts "Saving DC IP: #{@saved_dc}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment