http://www.perlmonks.org?node_id=1218215


in reply to Regex to catch IPV4 and IPV6 whenever ip appears withing brackets

Perl probably has a module for that: Regexp::IPv4 Regexp::IPv6