Determine if a string is a valid IPv6 address. Not as widespread yet. Consist of eight colon-separated 16-bit hex numbers with zeroes suppressed.
#!/usr/local/bin/ruby
# Determine if a string is a valid IPv6 address. Not as
# widespread yet. Consist of eight colon-separated 16-bit hex
# numbers with zeroes suppressed.
num = /[0-9A-Fa-f]{0,4}/
pat = /^(#{num}:){7}#{num}$/
v6ip = "abcd::1324:ea54::test::ipnull"
ipv6_pat = Regexp.new(pat)
if v6ip =~ ipv6_pat
puts "yes"
else
puts "no"
end