"Chris St. Clair" <[EMAIL PROTECTED]> writes:
> 0xc0.168.000000001.1
> 
> Coming up with an effective regex to match that might be tough.

Not really.  Here's a Perl regexp that matches the general syntax:

  /^(0x[\dA-F]+|\d+)(\.(0x[\dA-F]+|\d+)){3}$/i

Strings matching this regexp can be converted to a struct in_addr
using inet_aton() on OSes whose libc provide it; those stuck with
inferior OSes can obtain the code from e.g. FreeBSD's CVS tree:
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/net/inet_addr.c

DES
-- 
Dag-Erling Smørgrav - [EMAIL PROTECTED]

Reply via email to