
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/