or, a slightly faster version:sub could_be_a_host { my @a = split /\./, shift, -1; @a > 0 and not grep !/^[a-z0-9\-]+$/i, @a and not grep /^\d+$/, @a and not grep /^-|-$/, @a; }
(Modified slightly per tye's suggestion, thanks!)sub could_be_a_host { my @a = split /\./, shift, -1; return 0 unless @a; for (@a) { return 0 unless /^[a-z0-9\-]+$/i; return 0 if /^\d+$/; return 0 if /^-/; return 0 if /-$/; } 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Test the syntactic validity of a domain name
by tye (Sage) on Sep 20, 2000 at 21:01 UTC | |
|
RE: Test the syntactic validity of a domain name
by japhy (Canon) on Sep 20, 2000 at 21:05 UTC | |
by tye (Sage) on Sep 20, 2000 at 21:07 UTC | |
by japhy (Canon) on Sep 20, 2000 at 21:13 UTC | |
|
RE: Test the syntactic validity of a domain name
by ncw (Friar) on Sep 22, 2000 at 18:00 UTC | |
|
Re: Test the syntactic validity of a domain name
by extremely (Priest) on Nov 18, 2000 at 13:22 UTC |