I am developing a Ruby on Rails application by using Ruby v1.8.7 . My question is more about Ruby language.
I know there is a build-in Ruby library named IPAddr in Ruby v1.8.7 . It handles IP address related issues well. But, seems it does not provide any method to check IP address format.
Could someone provide me a good way to check IP address format(IPv4 and IPv6 addresses) in Ruby? Thank you.
P.S.
I tried a regular expression way:
ip_regex = ^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.
([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$
ip_addr='127.0.0.3'
ip_addr =~ ip_regex
But it does not work...