regexp for IP address / host-domain 
Author Message
 regexp for IP address / host-domain

I know I've seen this somewhere but can't remember where. Is there a
regexp that will match an IP address in the form of 1.2.3.4 or similarly
hostname.domain.orgtype ?


Thu, 26 Apr 2001 03:00:00 GMT  
 regexp for IP address / host-domain

Quote:

> Is there a regexp that will match an IP address in the form of 1.2.3.4
> or similarly hostname.domain.orgtype ?

Yes, there is. But you probably don't want to insist on there being four
numbers in a dotted-quad, since future IP addresses may have more and
current ones may have fewer.

Just what is it you're trying to do? If you're looking to validate an
address, you should probably use DNS. If you're looking to pick a
valid-looking name out of text, you should probably write the expression
based upon the DNS host name standards. But maybe this simple pattern is
all you're looking for. Hope this helps!

    [^.\s]+(?:\.[^.\s]+)*

--
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



Thu, 26 Apr 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Find Domain Name via IP address

2. Getting a host's local ip addresses

3. IP address -> Host name using Perl

4. Regex to capture ip address from hosts file

5. Getting a host's local ip addresses

6. IP Address to Host Name code WANTED

7. need regex to extract domain.name from host.domain.name

8. Regexp to match IP Address

9. Hosting companies, find all domains that are hosted

10. Need resolver from IP numeric address to alphabetic address

11. How to find IP address by MAC address?

12. Finding an email address by ip address

 

 
Powered by phpBB® Forum Software