in reply to IPv4 regex

Not sure if it matters to your program, but within the range of "numerically valid" IP addresses that everyone's suggestions capture, there are some ranges that are reserved by certain protocols. For instance, the subnet 224.0.0.0, is reserved for Cisco multicast group addresses. There are other examples, as well, such as reserved private subnets 172.0.0.0 and 192.0.0.0. These subnets are not publicly routable. There are other examples, as well.
Just thought that I would kick in my $.02, in case it mattered
Update:As merlyn has adeptly pointed out, in an indirect fashion, Tuna should NOT post before getting caffeine into his system. Sorry for the misinformation.

Replies are listed 'Best First'.
IANA Reserved Private Addresses
by merlyn (Sage) on Feb 18, 2001 at 20:25 UTC
    It's not 172.* and 192.*. According to rfc1918:
    The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internet +s: 10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)

    -- Randal L. Schwartz, Perl hacker